日期:2014-05-17 浏览次数:20975 次
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>
推荐阅读更多>
-
50分求一算法解决思路
-
JDBC操作解决方案
-
eWebEditor(JSP版)在Linux下面运行出错有关问题
-
有做ios的吗 有那么好挣钱吗解决方法
-
Eclipse+Nokia开发包 的有关问题
-
jsp页面怎么接收json数据
-
关于cookie的有关问题
-
JAVA学习有些枯燥
-
求购协同办公系统,该如何解决
-
超链接运行程序有关问题
-
eclipse运行程序时出现java.lang.OutOfMemoryError解决办法
-
关于spring和SSH框架,该怎么解决
-
关于导入包的有关问题的一点疑惑,请大家指教
-
小有关问题
-
java自定义文件格式,该如何处理
-
在if下定义FileInputStream如何出错
-
新手求教 字符串和数字相加有关问题
-
请问一个有关问题,请大侠们帮忙,多谢
-
高手请帮我看一下这个小程序如何出错呢
-
ssh整合 需要哪些jar包?该如何处理