日期:2014-05-17 浏览次数:21045 次
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>
推荐阅读更多>
-
跪求:java.sql.SQLException: OALL8 处于不一致状态,违反协议,怎么解决
-
关于Spring 的scope="prototype"的有关问题
-
一个自学将近一年的专科生面试的迷茫->java解决方法
-
java中关于ResultSet的方法解决办法
-
问个关于复选框的有关问题。
-
【征集】CSDN的Java技术版的LOGO解决思路
-
交付表单返回false?
-
新手发现java7 API的一个bug?解决办法
-
J2SE生手求教!
-
GUI按钮如何变成一张图片
-
JSP开发遇到异常,看不懂,求大神,
-
求援!为什么输出素数会有9,27这些,还少了2
-
用相同路径的类替换jar包中的类有关问题
-
解决不了小弟我会死不瞑目!
-
Jtable中可不可以添加JButton,该怎么处理
-
使用java mail发送邮件报告的异常,请一二
-
系统靠山数据修改之后前台页面自动有消息提示
-
hibernate 定义表空间解决方法
-
在jsp中如何做,才能实现以下功能
-
vc转java,希望大家伙儿指点