日期:2014-05-17 浏览次数:20929 次
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相关,关于Dtree的有关问题!
-
[请问]高手一个关于J2ME发送短信的有关问题(三星手机)
-
关于使用HTT,该怎么处理
-
刚开始学javaWeb,有点迷茫,大哥大姐们给点好的方法,该如何处理
-
MESSAGE: Software caused connection abort: socket write error
-
ckeditor上传资料
-
java 逻辑题,该如何处理
-
JSP中使用Onclick传值到Servlet,是怎样?新人——求指教!解决办法
-
db4o中明明存在却“找不到对象”的bug,怎么解决
-
导出JAR后系统找不到指定文件有关问题
-
一个弱弱的有关问题的,传说的中的分页技术
-
请大家帮帮我,怎么将pkcs1的签名转换为pkcs7的签名
-
strust2.3.15.3 <sx:a>标签的跳转有关问题
-
[,高分]怎么设计关闭网站通知
-
求助链接有关问题
-
下拉菜单解决方案
-
请教各路tomcat 的 localhost不能自动生成 为什么
-
在J2EE项目中处置浏览器的缓存
-
aop:poincut时出错误