日期:2014-05-17 浏览次数:21173 次
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>
推荐阅读更多>
-
兄弟帮下忙!感激不尽!JAVA2D绘图中如何实现画的图象被选中?还有实现图象的移动
-
求教菜单的链接有关问题
-
JAVA连接SQL2000的有关问题
-
正则 /\D/g,该怎么解决
-
- 点击按钮 运行 bat文件
-
困扰的有关问题,javaweb该怎么学习
-
集合报空指针 当集合为空时如何样让程序继续正确运行
-
java获取jsp页面信息生成dat文件,该如何处理
-
showModalDialog传值相关有关问题
-
java发送邮件找回密码求解决办法
-
Java包Cipher类,关于DES加密有关问题
-
往ServletContext中的数据为null
-
java的,截取字符串解决办法
-
关于多附件上传的有关问题
-
javabean的有关问题: Cannot find any information on property
-
大衣的外口袋招贼,贵重东西放不得。该如何解决
-
初学者在GUI遇到的一点点有关问题~求帮忙
-
请教myeclipse这样提示异常是什么意思
-
对传智播客很大失所望
-
J2SE知识点归结笔记(二)-Java基础知识