日期:2014-05-17 浏览次数:20712 次
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>
![]()
推荐阅读更多>
- 用struts的upload上传文件时出现了错误.请大家帮小弟我看看哪里有有关问题
- 帮小弟我看看这个有关问题如何解决
- java 规律数组 找出 每个索引间的 缺失的值,该怎么处理
- SPRING 用户登录,该怎么解决
- jmap出错解决方法
- netbean 用jdbc连sql2005express 有关问题 (sqljdbc_4.0已导入项目)
- 能不能把javascript中的变量在网页中文本框中读取出来,该如何处理
- 标题难度(1星)
- ,调用第三方程序倒底能不能实现
- webservice与外网端口共用有关问题
- 关于JAVA摄像头控制解决思路
- *JAVA设置代理服务器访问网页(100分)*解决思路
- win7上面的IE8开发人员工具检测不了脚本
- 急MQ Server有关问题
- frame中获取session有关问题
- 真心求前辈们帮小弟我推荐一个好的IT公司
- 关于Scanner的一个warning的有关问题
- java文件流上传的路径设置有关问题
- 数组在排序前后是同一个数组么,该怎么处理
- 线程有关问题,关于对象在线程中的存储情况