日期:2014-05-17 浏览次数:20976 次
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>
推荐阅读更多>
-
二维数组的倒序有关问题
-
基于http服务管理系统,该如何处理
-
Map< extends K, ? extends V> m这是什么意思?解决办法
-
获取界面返回的json有关问题
-
内部类这一块遇到有关问题啦
-
问个弱智 System.in.read()有关问题
-
正则表达式有关问题?
-
JAVA输入有关问题
-
求!关于用java判断输入三个数组成什么三角形
-
在win7系统上打不开webdav网络文件夹,这是为何,哪位大侠了解?该如何处理
-
jsp连接postgresql的有关问题
-
jQuery.ajax()请求struts2数据 回到data值了undefined
-
为什么vista安装tomcat出有关问题 有什么解决办法
-
java 获取现阶段系统时间前24个小时 “时”的数组
-
考考大家,以&开头的是什么编码?解决办法
-
关于instanceof运用,一个小程序里出错。该怎么解决
-
怎样遍历table 每一行中的单元格,该如何解决
-
一个“不小心”的笑话!该怎么解决
-
S2SH,联网情况下正常运行 断网时启动tomcat发生错误
-
JfreeChart1.0.2画饼图怎么去掉Label显示