日期:2014-05-17 浏览次数:20738 次
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>
![]()
推荐阅读更多>
- 新人、学习easyUI需要做的准备工作有哪些
- test,该怎么解决
- sql向mysql数据库迁移,分页出现有关问题,报的应该是 关键字异常,但是死活发现不了
- J2ME平台下手机游戏移植的体会
- com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。该用户与可托 SQL Server
- URL直接转化成String类型有关问题
- memcached怎的移除down的节点
- java调用存储过程,结果集为空,该怎么处理
- struts2 上传文件有关问题 就大神解答
- java。大侠帮忙找找异常
- JAVA学习入门 对初次接触者 相当有用解决思路
- java中生成word文档,要有报表样式
- 一个关于getRealPath的有关问题
- Eclipse 插件解压出现这种有关问题怎么处理? 多谢
- 怎么把Iterator<Integer>转换为int型
- 怎么打开验证页面
- 关于ireport的HTML打印有关问题
- 要工作了; 请诸位大侠指教下
- hibernate INTEGER 有关问题
- 关于htmlparser运用,求高手,加班的人伤不起啊