日期:2014-05-17 浏览次数:20995 次
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>
推荐阅读更多>
-
servlet传值给jsp页面出现疑问号
-
请求高手帮助,特别着急该怎么解决
-
hibernate联接mysql报错
-
求帮忙批改源码
-
读取文本文件时CPU 100% ?奇怪了。解决思路
-
frame有关有关问题
-
解析excel资料
-
散分了,点小弟我申请的域名有分`
-
关于Spring 的scope="prototype"的有关问题
-
哪位高手知道 FileDescriptor 的作用
-
怎么安装tomcat6.0啊
-
关于网页检测有关问题
-
Map 集合有关问题求教
-
关于jdbc连接的语句,简单,但是没遇到过的连接有关问题
-
java里边有new来创建一个对象,为什么还要Class.forName?解决方案
-
自动插入表格,怎样定义插入个各列文字的颜色?该怎么处理
-
刚学习ibatis遇到java.lang.ExceptionInInitializerError,不能创建SqlMap实例,求
-
java绘图,求赐教
-
Java-基础解决办法
-
Java报错解决办法