日期:2014-05-17 浏览次数:20822 次
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>
推荐阅读更多>
-
作一个小游戏,看你是不是初学者
-
浅谈J2EE十三个轨范
-
Hibernate连接DB2分页查询报错,该怎么解决
-
怎么在spring配置多个数据源
-
Hibernate的占位符有关问题
-
JAVA中的单例模式是什么 ?
-
关于java中的Servlet中的一些题目,该怎么处理
-
刚出来工作,求大神们指点.解决方案
-
考考你们的java基础。该怎么解决
-
行行好,朋友们帮帮忙?该如何处理
-
求小游戏代码,该如何处理
-
求jacorb的运用和作用
-
小弟我的男朋友国庆全部时间留在宿舍编程,不出去了,小弟我是不是该甩了他
-
减缩图片kb大小
-
数据库值发生改变如何通知前端页面显示做相应改变
-
做项目的过程中,有用到portlet,但是本人对portlet一点都不了解,请教哪位高手有好的有关portlet的学习资料,给小弟我一份啊再此表示非常的感谢
-
SSH异常.求高人解决
-
!j2me内存不足有关问题!
-
JSP删除增加的有关问题
-
关于好的编程习惯的!