日期:2014-05-17 浏览次数:20687 次
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.sql.SQLException: 结果集已耗尽,该怎么解决
- 求注销的代码解决思路
- java socket编程疑点
- 简单有关问题。eclipse这写英文是什么
- 定义了bean,为什么还是出现No getter method for property name of bean 异常
- java 的 eclipse有关问题
- java.lang.IllegalArgumentException: Can't convert argument: null
- SSH2添加事务代理出错折腾小弟我多时啊
- <html:text>中特殊字符插入到mysql时出现乱码
- java依据数据库展开树
- 帮一个忙好不?该如何处理
- 小写金额转大写,在windows好用linux不出角分,该怎么处理
- 可否将一个输出流复制成多个流
- 调用ActiveX后,如何不让刷新页面
- 大家推荐几个牛点的Java技术QQ群,介绍下技术群的特色<font color='red'>[推荐]</font>解决方案
- 一个重绘的有关问题
- 在Linux上Java怎么执行远程Windows命令?
- 在JSP中用windows media player怎样实现多首歌曲自动循环播放?该如何处理
- model层的类如何直接赋值给dto层的类
- 怎么取hidden值