日期:2014-05-17 浏览次数:21018 次
public class SelectCourse implements java.io.Serializable {
// Fields
private String snu;
private TearcherInfo tearcherInfo;
private StudentInfo studentInfo;
private CouresInfo couresInfo;
private String ctime;
private Integer cgrade;
/*get、set方法省略*/
public String addSelectCourse() throws Exception {
TearcherInfo tearcherInfo = new TearcherInfo();
StudentInfo studentInfo = new StudentInfo();
CouresInfo couresInfo = new CouresInfo();
System.out.println("学号:" + getSelectSnu() + "教师编号:"
+ getSelectTearcher() + "课程编号:" + getSelect1Course());
tearcherInfo.setTnu(getSelectTearcher());
studentInfo.setSnu(getSelectSnu());
couresInfo.setCnu(getSelect1Course());
selectCourse.setStudentInfo(studentInfo);//从此处开始出错!java.lang.NullPointerException
selectCourse.setCouresInfo(couresInfo);
selectCourse.setTearcherInfo(tearcherInfo);
selectCourse.setCgrade(getCgrade());
selectCourse.setCtime(getCtime());
try {
adm.saveSelectCourse(selectCourse);
} catch (Exception e) {
return "input";
}
return "success";
}
<hibernate-mapping>
<class name="com.yaxing.domain.SelectCourse" table="SelectCourse" schema="dbo" catalog="Student">
<id name="snu" type="java.lang.String">
<column name="Snu" length="16" />
<generator class="assigned" />
</id>
<many-to-one name="tearcherInfo" class="com.yaxing.domain.TearcherInfo" fetch="select">
<column name="Tnu" length="10" not-null="true" />
</many-to-one>
<many-to-one name="studentInfo" class="com.yaxing.domain.StudentInfo" update="false" insert="false" fetch="select">
<column name="Snu" length="16" not-null="true" unique="true" />
</many-to-one>
<many-to-one name="couresInfo" class="com.yaxing.domain.CouresInfo" fetch="select">
<column name="Cnu" length="10" not-null="true" />
</many-to-one>
<property name="ctime" type="java.lang.String">
<column name="Ctime" length="10" />
</property>
<property name="cgrade" type="java.lang.Integer">
<column name="Cgrade" />
</property>
</class>
</hibernate-mapping>
推荐阅读更多>
-
hibernateTemplate.save(Object) ID策略有关问题。
-
EJB项目如何导入Jar包
-
jsp的来帮帮小弟
-
懂得flex和工作流的大侠来指点上.关于java中自定义表单和工作流程的有关问题
-
求救:java操作EXCEL的有关问题 ~
-
数据库奇怪的有关问题
-
ServerSocket accept的有关问题
-
jsp页面跳转时.怎么保持原来文本框中的值?
-
int数组有{1,2,1,3,3,2},如果数组里的值重复,返回true(急求),该如何处理
-
求帮帮忙忙。多谢
-
如何在服务器端获取客户端得信息!
-
java中对线程的两种方法的使用,该如何处理
-
一个求解数独的代码,哪位高手能给分析下
-
*请教:怎么接受类返回的java.util.List类型,先多谢了!
-
如果用Jquery在用户点击页面上角落的X的时候添加事件解决方法
-
model层的类如何直接赋值给dto层的类
-
急救!字符串转换解决思路
-
java中的字节流和字符流到底是咋回事
-
关于struts2中struts.xml有关问题。求解答
-
javascript 函数调用有什么有关问题,请