日期:2014-05-17 浏览次数:21062 次
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>
推荐阅读更多>
-
web 刷新 有关问题,大家帮给点意见
-
请教一个小技巧`
-
敬求排列组合种算法,见描述
-
相当的难!解决思路
-
<input type="file" />浏览时只显示指定文件类型解决方案
-
想写个程序,找工作用,请大家给点意见,来者有分解决方法
-
三个月实习就这样结束了!即将要转正,可是小弟我想小弟我该离开了
-
学JAVA英语不好怎么处理啊
-
办完离职了.年前最后一次散分,该如何处理
-
迷惑了?java书看不下了,大家帮我看看这有关问题
-
100分求帮小弟我翻译一篇论文摘要(字数不多,内详)
-
为什么浏览器会报对象为空呢
-
用struts2+ajax表单提交时,有哪位高手遇到过这个错误?异步提交不需要result
-
jdbc将数据惠存数据库中
-
Java Date取出时间与系统时间对不上解决办法
-
tomcat 启动正常 但进不了欢迎界面http://localhost:8088解决思路
-
update语法异常!弄一下午了
-
servlet 多谢
-
java.util.ArrayList cannot be cast to com.hxll.hr.entity.SalaryStandard解决方法
-
jsp页面如何调用java方法