日期:2014-05-17 浏览次数:21177 次
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>
推荐阅读更多>
-
String是不是是基本数据类型
-
安装完JDK,需要设置哪些东西,才能开始运行第一个JAVA程序啊解决方法
-
多客户端手机应用有关问题
-
难缠有关问题,难缠到吐血,请大家出主意
-
郁闷的环境变量有关问题
-
Servlet Filter 类型转化出了有关问题 大家帮忙看看
-
这么多标签,哪个好点?el,jstl,velocity,freemarker,ognl,该如何解决
-
老师发了份JAVA试卷,但没给答案,大家帮忙看看有没错.多谢
-
新人遇到的简单有关问题
-
急tomcat的有关问题,好奇怪!
-
struts2有关问题-There is no Action mapped for namespace
-
关于变量值的共用有关问题
-
解析xml引起数据库死锁
-
SE做学生成绩管理系统的有关问题
-
Caused by: java.net.ConnectException: Connection timed out: connect
-
用poi 读取excel2007 创造XSSFWorkbook对象时 java.lang.OutOfMemoryError: Java heap space
-
Java零基础 推荐视频教程解决方法
-
高分jdbc有关问题
-
不能正确检测重复帐号?该如何处理
-
关于数据库和实体类的有关问题