日期:2014-05-17 浏览次数:20883 次
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代码中的异常原因”
-
获取用户名一般,获取密码却为空
-
tomcat服务器只能用如IP(如172.16.45.84)打开,不能用localhost打开解决方案
-
java基础有关问题 多谢
-
一个字符串处置
-
两个字符串数组怎么比较是否相等
-
jsp动态增添的数据级联删除
-
总算明白java是何等的垃圾
-
求韩顺平老师满汉楼系统文件(要需求文档、源代码、数据库跟素材)
-
求教,怎么获取局域网的IP
-
为什么标签会报错呢,该如何解决
-
急web start 的jnlp中如何配置可以从自定义的地址下载 jre
-
为什么这段代码编译时会报错?该如何处理
-
请教c++中lpctstr对应JAVA什么类型
-
UltraEditor怎么设置
-
傻瓜,初学者有关问题
-
面试回答对多少比例有关问题HR会让你进
-
HttpClient 获取图片的一个有关问题
-
网站部署空端口和空工程名解决思路
-
错误转译理解