日期:2014-05-17 浏览次数:21093 次
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>
推荐阅读更多>
-
JSTL的C标签一问解决办法
-
为什么过不去呢?解决方法
-
java.lang.NumberFormatException: For input string: "previews"解决办法
-
请问:fmt标签限制小数位数为何不起作用
-
求搜寻文章题目代码
-
关于j2me图片缩放算法的有关问题
-
scjp有关问题,tell me why~
-
今日面试不会 郁闷啊
-
如何让Iterator实现多个集合
-
List元素罗选和排序
-
关于中文文件的下载有关问题
-
急求前辈们指导,有个小异常
-
为何总是提示:There is no Action mapped for namespace / and action name mailAction
-
发现自各儿居然懒了半年~小小在博客更新了一个Aspect系列
-
求java数据库系统开发案例甄选源代码
-
this,toString一些基本的有关问题,请多指教
-
帮忙看看 ,解决即给分 下拉菜单的有关问题
-
关于session.getAttributeNames()解决方法
-
java新手有关问题
-
用struts2写了一个action,在浏览器直接访问action 的地址,发现第一次访问execute方法被执行一个,第二次execute方法被执行3次!解决方法