日期:2014-05-17 浏览次数:21091 次
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去哪个方向发展前景好?不想毕业就失业、
-
高手帮忙啊jsp页面调用javascript有关问题.
-
java web 登录次数限制,该如何解决
-
求一简单正则表达式 一个字符串: "ip" 或 "ip\" 如何写
-
刚学完面向对象 书上有个选择题不理解 求解解决办法
-
java后台调用URL的有关问题
-
怎的设置多个tomcat使用同一个端口
-
我是安装版的tomcat,我想升级如何办,可以直接升级吗
-
请问诸位大侠,有没有在线访谈系统的开源资料,最好是电子政务这一块的在线访谈系统,多谢了
-
大家帮帮忙:小型宠物店系统用了几分钟后特慢?该怎么解决
-
关于◎SuppressWarnings("Unchecked"),该怎么解决
-
js获取不到ID,该如何解决
-
新手上路,请多指教解决方法
-
添加的时候出现反射机制异常
-
请教:做SP服务需要什么设备?以及申请流程
-
新手有关问题
-
测试发帖,该怎么处理
-
用那些jar能生成word文档呢?该如何处理
-
求java调其它语言接口或方法的视频,反之也行!该怎么解决
-
怎么利用随机数生成一个随机数组