日期:2014-05-17 浏览次数:20818 次
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>
推荐阅读更多>
-
UDP byte[] 发送十六进制数据时出现的有关问题
-
0x06 的高下字节地址是什么
-
在调用obj.wait()前为什么要先得到obj的monitor解决方案
-
为什么函数不运行?该怎么解决
-
判断字段是否为空解决思路
-
这是刚学Jquery遇到的有关问题,他也不报错,可就是用不了
-
EL表达式返回值如何运算 ?
-
出现乱码的有关问题<很简单的一段html 麻烦各位看看 多谢>
-
javabean中的数据如何传递到javascript
-
有关Html的有关问题
-
请教Hibernate JPA 单表一对一双向关联配置
-
关于filter的处置response
-
关于quartz的一个奇怪的有关问题
-
Java使用XFire调用WebService接口(初学者就别进来了…)
-
简单 取消数组重复元素 的有关问题?
-
一个老软件工程师的建议-看完了…你决定继续做编程
-
本人初学者求高手解释啊这程序哪里出错了?小弟我很费解啊
-
图中求最短路径并把路径记录下来解决方法
-
不会连接运行客户服务器连接,高手帮小弟我!
-
如其利用JSP页面读取一个文件并把其传到服务器