日期:2014-05-17 浏览次数:20696 次
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>
![]()
推荐阅读更多>
- 财务报销慢如何催促
- JSP+Servlet+JavaBean中,Servlet的使用方法解决办法
- ibatis mysql转oracle有关问题
- 列位大侠帮个忙,该如何处理
- java 如何把数据库中符合条件的数据一条条的添加到list里面
- 关于JAVA与数据库连接的小疑点
- 求助各位大侠:如何用jsp实现文件的上传和下载
- 字段加密的有关问题
- 正则有关问题!头糊了
- 可以安装在win7系统的sql server
- json,action,jsp的有关问题,困扰好几天了
- 根据条件判断checkbox提交下拉列表框数据,该怎么处理
- jbuilder报URL: Unable to open location: Document not found on server错,该怎么处理
- 设计数据库的有关问题
- 新人疑问,在公司遇见诡异的软件应用有关问题
- android 两个activity如何通信
- 权限有关问题
- 一段JAVA代码,里头有一些提问,希望大家帮忙简答下
- java无窗体鼠标流畅拖动如何实现
- java的socket,如何同时侦听双网卡?包括127.0.0.1