日期:2014-05-17 浏览次数:20987 次
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>
推荐阅读更多>
-
反射的有关问题
-
.docx文件转base64 再转回.docx文件 乱码有关问题 求帮助
-
Extjs解析struts2返回的json数据异常求给指点一下 多谢啦。(分不多了,不好意思)。很急的
-
jsp 向数据库中提交数据为什么不成功?而获一种表达就能,很怪!大家指教!多谢
-
Hibernate4.3.1 创建session工厂的有关问题
-
httpsession创建后是否要显式关闭?若要的话,求关闭时机及方法?解决方法
-
js里面如何通过el表达式获取后台数据
-
怎么对一个字符串按逗号和分号分割成数组
-
Hibernate Select new(Entity) 的 有关问题,请大家帮忙解决
-
return this,该怎么处理
-
刚入门,请帮助调试jsp程序!该如何处理
-
SVN到处项目的有关问题!
-
不要javabean做分页,怎样保存刷新之前的page值
-
小弟是JAVA新手,求大家帮忙看上这个小程序,多谢
-
如何统计行数
-
Integer类的方法~新手求救~解决办法
-
请教哪位高手有对结果分类的算法
-
java web开发,该如何处理
-
android手机应用开发,与java关系,具体学习方法
-
打造高薪软件工程师-威迅教育一年成就你一生,该怎么解决