日期:2014-05-17 浏览次数:20748 次
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>
![]()
推荐阅读更多>
- 自定义标签怎么进行spring的@Autowired
- sql预加工
- JavaMail邮件发送,可以不经过邮件服务器,直接发送吗?解决方案
- 关于RFID的LLRP协议的javaLTK,有理解的请进
- 帮忙写一个oracle的id生成器!解决办法
- 干开发,笔记本性能瓶颈主要在那些方面
- java程序在liunx起步另一个程序
- 小弟念配一台笔记本、求懂的大哥指导
- JAVA中文字符串怎么分解成字符数组
- extends 与 implements 有什么区别,该如何处理
- 登录以后跳转到上一次请求页面
- Unable to locate appropriate constructor on class,该如何解决
- 视频网相关,该怎么解决
- 求教一个j2ee的新手有关问题(有关error.page)
- 这个的正则表达式如何写
- ?username=122是什么意思?该怎么处理
- Java SE: 对象调用,该怎么处理
- mysql 1~12月份sql查询语句解决思路
- 关于ITEXT的有关问题
- C++软件工程师 想学下JAVA 求推荐入门书