日期:2014-05-17 浏览次数:20979 次
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常量池解决方法
-
java SWT有关问题
-
文本框上的ActionEvent事件的小疑点
-
求解答一个Java线程死锁模拟程序失败的原因解决思路
-
相关JSP
-
java web开发解决办法
-
从SQL SERVER2000导入到oracle解决思路
-
线程有关问题 ,
-
编译报错unchecked or unsafe operations,该怎么解决
-
求解一个后台异常
-
Java小白的几个疑义
-
自己编写框架-LibraFramework,该怎么解决
-
jsp+mysql有关问题
-
当Form参数enctype设置为"multipart/form-data"怎么取文本内容
-
资料读取代码看不懂
-
struts2标签 遍历map集合 第二集合显示不出来,该怎么解决
-
imA申请 应用服务器 版版主,该怎么处理
-
localhost:8080打不开,该怎么处理
-
jsp页面中加了<table>元素后,页面出现了一大片空白后才出现表格?解决方法
-
提问JAVA函数调用的有关问题