日期:2014-05-17 浏览次数:20902 次
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>
推荐阅读更多>
-
解决此js有关问题100分只给你一个人
-
小弟我是个悲剧的面试官,求教
-
Spring MVC HTTP ERROR 404,该怎么处理
-
jni中如何样返回数组参数,JNIEXPORT jint JNICALL Java_com_gy_image_HotKeyHookManager_startHotKeyHook(JNIEnv * env, jobject hookMa
-
java有没有读取文本文件里某一起的命令啊
-
急后天就要考试了,大家来帮帮忙吧
-
用poi读取EXCEL有关问题
-
jfreechart横坐标太密,有没有办法只显示部分横坐标?该怎么解决
-
ssh框架中button传值有关问题
-
求牛人在空闲的时候帮小弟我解决下,用MyBatis,Spring,Struts2.多谢
-
想用上面的代码随机产生两个不同的单字符字符串,如“A”,“8”,请帮看看,什么实际仍然会重复
-
jsp传值与取值有关问题
-
review页面回到后,没有刷新?
-
大神,将本地pdf文件上传到FTP服务器后,打开什么都没有
-
jsp输出数字字符有关问题
-
为什么保存不成java格式的。记事本里写的。该如何处理
-
求助,有没有熟悉mxgraph的,cursor有关问题
-
使用POI 读取 Excel 文件,读取手机号码 变成 1.3471022771E10,该怎么解决
-
struts 跳转时页面空缺
-
J2ME 闹铃的实现,该如何处理