日期:2014-05-17 浏览次数:21080 次
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>
推荐阅读更多>
-
springMVC3.0+hibernate3.0缓存有关问题
-
作为一个java新手,很纠结.该如何解决
-
一道策略模式联系题,希望大侠们帮小弟我做一下!
-
java学到什么程度可以一般去应聘
-
JavaEE Web开发使用框架之_Struts2
-
jquery.post请求为啥得到的是html
-
为什么小弟我做的最后的一个按钮总是窗口大小
-
javascript动态生成有ID的,ID为变量,如何获取ID的对象
-
变量可以调用步骤吗
-
啊小弟我初学者,望大侠们多帮助
-
生手 问答
-
JTextPane 通过鼠标选中图像有关问题。懂的请进
-
mysql 简化 or能否实现?该怎么解决
-
web 开发struts前途
-
hibernate3里没有hbm2java的工具了吗解决方法
-
jsp页面交付乱码
-
问点JAVA工作有关问题
-
mongodb的有关问题
-
struts2类型转化的有关问题
-
java.sql.SQLException: null, message from server: "Host '