日期:2014-05-17 浏览次数:21123 次
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>
推荐阅读更多>
-
新年好:对于java.lang.IllegalArgumentException: Can't convert argument: null
-
tomcat6.x 启动的异常和警告 信息
-
SSH2的事务有关问题
-
拜谢大家伙儿指路!
-
为什么jar游戏文件不能用ke模拟器打开呢?该如何处理
-
帮看一个jdbc获取oracle存储过程自定义类型的有关问题。
-
java prepareStatement的使用解决思路
-
每小时访问量10万的系统,该怎么解决
-
怎么在jsp页面中实现上拉菜单的功能
-
jButton.setToolTipText(String)小疑点
-
在servlet中实现下载文件后,怎么按行输出到txt文件中
-
提一个关于线程的概念有关问题
-
前辈给介绍些学习java用的资料解决方案
-
求帮看看linux执行java class发生错误
-
jsp回车提交画面的有关问题
-
myEclipse,javabean里利用存储过程删除记录出有关问题
-
Servlet解决思路
-
关于添加struts框架的有关问题
-
httpclient 4.1.3 交付https登录表单失败
-
求高手解答网站安全机制或者是说安全证书的有关问题