日期:2014-05-17 浏览次数:20873 次
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>
推荐阅读更多>
-
【粗壮事了,粗大事了】准备制作一款C#的api方便java学习者学习
-
哪位高手有JB编译器的可执行文件
-
jsp页面重复刷新有关问题
-
没人散分。为什么没人散分尼。究竟为啥没人散分尼。
-
java既是有了互斥锁了,那么读写锁似乎有点重复
-
程序怎么判断当前手机操作系统是symbian还是wince
-
基本数据类型的 == 比较解决思路
-
在struts2权威指南那本书里,在struts2当中,有一个radion单选匡,里面的list属性为“#book.boos”后面是books是如何来的
-
在 MySQL 中怎么设置一个表的记录不能被删除
-
intValue()方法调用有关问题
-
ssh框架整合时遇到的一个很令人纠结的有关问题,望各位大侠不吝赐教,不胜感谢
-
struts2中set get施行顺序
-
XFIRE 的动态调用,该如何处理
-
java 线程的wait和notify有关问题
-
求救:tomcat和java进程有关问题
-
关于FCKeditor保存信息取出至FCKeditor中的有关问题
-
win7 tomcat jsp 内往访问有关问题
-
很急在java中取得referrer的有关问题
-
怎么实现类似于C里的int sort(int a[])的数组排序
-
关于tree组件的有关问题