日期:2014-05-17 浏览次数:20839 次
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>
推荐阅读更多>
-
gui编程解决方法
-
jsp 中怎么显示tomcat文件目录上的图片
-
关于取结果集的有关问题
-
[Java EE 7] Servlet 异常处理
-
小弟我写了个JSP的登录页面,老是提交不过去,大家帮忙看看了多谢
-
jsp:useBean找不到种,为什么呢
-
数据库存储存取有关问题(急)
-
oracle左连接改成+的写法,出现ORA-01417异常
-
网站访问量1200IP/天,该用什么数据库?小弟我现在用的是ACCESS数据库,这个访问量是不是该换成SQL数据库
-
高手们指点指点啊该如何处理
-
安卓和J2EE哪个更容易上手一些?哪个更有前景一些,该怎么解决
-
在同一个java文件下,可以有几个public类解决办法
-
请教怎样解决部署的有关问题!的多谢大家的帮助了
-
Openmeetings安装有关问题
-
JSP乱码MYeclipse,该怎么处理
-
用jfreechart的在jpanel中添加图表的有关问题
-
小弟我在JCreator中写的代码,在eclipse中都能运行,但是在MyEclipse报了好多错
-
j2me新手,一个很简单的有关问题
-
真的要用hibernate吗?该怎么处理
-
Struts2跳转到一个action,而且要带俩个参数