日期:2014-05-17 浏览次数:21108 次
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 如何读入不确定个数数字
-
求Java
-
关于ssh的一个有关问题
-
火车票二维码扫描解析,该如何解决
-
主线程创建了子线程,怎么让主线程退出,而子线程仍然运行
-
问一个list处理有关问题
-
发个帖问个小疑点,主要是送分,来者都有的
-
关于java定时任务,该怎么解决
-
请问神人,把小弟我从数据库中读出来的数据写入独立log4j日志文件,要如何弄
-
在dwr中怎么把回调的返回值String[]变量赋给javaScript变量
-
Jboss 打不开,不知道怎么回事啊求高手
-
【讨论】是不是在公司里,老板叫你做什么,就做什么?该如何处理
-
java中怎么判断某个IP是否连通
-
怎么隐藏多级下拉框的子下拉框
-
关于jsp修改Oracle数据库中记录的有关问题
-
这个String str为啥没变?
-
Hibernate初学者的疑惑:为什么要使用Hibernate
-
华为面试第一题就把小弟我整晕了!
-
请问关于CLOB