日期:2014-05-17 浏览次数:20926 次
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>
推荐阅读更多>
-
新手,学习hibernate时看到上面的语句
-
社交网站新近访客功能
-
JAVA或C的最基本的概念,困惑中……,
-
mybatis sql语句获取不到参数解决方案
-
什么是对象类型转换?解决办法
-
java中long门类转化Object类型
-
org.hibernate.exception.SQLGrammarException错误有关问题
-
大型网站如何实现页面静态化
-
tomcat启动一段时间后自动挂掉。该怎么处理
-
(期望加精)有关字符编码的有关问题,求解
-
Java 为什么这么设定呢解决办法
-
TO:喜欢嘲笑别人的人,该如何解决
-
一份找工作的无奈跟告白
-
英语日期的疑问,该如何处理
-
请教哪个jsp的网上商店比较好,要免费的
-
问下关于java读取ftp文件的有关问题(不是下载)
-
书上课题解决方法
-
上载的一个正则表达式的api-jakarta-oro-2.0.8.jar,应该把它放到什么位置?才能引用他包中的接口或类
-
在一个文本框中敲打回车以后,在展示界面中,也想出现回车的效果,如何做
-
Tomcat服务器,异常为404,找不到路径