日期:2014-05-17 浏览次数:20685 次
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>
![]()
推荐阅读更多>
- 面试题:统计单词中各个字母出现的次数?该如何解决
- Tomcat和Apache2.2.4整合有关问题
- 本人计算机专科刚毕业,想在北京找一份java工作,哪位高手能帮忙找找
- 页面跳转的迷惑
- 请教JSP的Session能不能保存数组
- Void返回值得有关问题
- java 的图形设计插件装上了为什么不显示,该怎么解决
- json转抽象DTO有关问题
- 问上大学的意义解决方案
- "main" org.hibernate.exception.SQLGrammarException:
- update更新语句异常
- 大伙来分析一下这个程序的输出结果
- 哥,小弟我还是个婴儿,有道题不会做了
- 求大神帮帮忙看看这个程序到底什么有关问题
- 用JAVA开发一个容易的web需要哪些软件
- 求援各位啊!使用JAVA编程实现对excel表格中单元格进行操作
- 帮忙看看映射哪里出有关问题了,hibernate映射有什么技巧
- Ajax Servlet 回来 中文乱码
- 中文正则表达式
- 实在觉得奇怪的有关问题,不知道什么原因了,问