日期:2014-05-17 浏览次数:21099 次
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>
推荐阅读更多>
-
Integer.SIZE如何用
-
大量不规则数据录入数据库有关问题
-
为何jsp request.getParameter取不到值,但request.getQueryString()却有值呢
-
请教如何在MyEclipse中配置websphere服务器
-
远程图片预览,该怎么解决
-
从网上下载的Middlegen-2.1.zip,解压后,build.xml文件有异常
-
一个面试题,对于购物网站的
-
关于线程的锁的一个有关问题
-
求解答关于 getWriter输出的有关问题
-
太长时间没来了,还有这么多分,三分攒RP了。解决思路
-
jsf的刷新有关问题,
-
这个有关问题,关系型数据库是否可以实现。怎么将类实例存放到ORACLE表中的某列中
-
JS刷新页面有关问题,求指点啊 啊
-
关于Serializable,为啥实现Serializable就能够实现序列化
-
一对多,安插的时候报错Could not execute JDBC batch update,请求帮忙
-
正则表达式小疑点
-
ibatis 如何样执行传入的sql语句呢
-
JSP 哪位老兄会二级下拉菜单啊教下吧,该如何解决
-
查询条件写得不对吗?该怎么解决
-
哪位高手能给小弟我一个在Java窗口中的Jpanel中显示一张图片的例子