日期:2014-05-17 浏览次数:20749 次
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>
![]()
推荐阅读更多>
- 实现接口时报错,请教为什么会报错
- 运用j2me开发嵌入式应用。linux平台,需要怎样配置环境
- 想买个nexus 七平板
- 请问:java读入文件有关问题
- socket能否返回一个值,显示短信是否发送成功?该如何处理
- javascript 怎么验证name=xx.xx的radio表单
- 关于smartupload下传组件的使用
- 郁闷啊 关于论坛结构!解决思路
- jsp导出excel遇到的样式有关问题
- j2me的前景,该如何处理
- 怎么在eclipse里引jspsmartupload.jar来上传文件
- myecplise8.5 未响应解决办法
- Need to specify class name in environment or system property
- 施用struts2查询数据库页面重复显示
- 问个import 有关问题 搞了一天了
- 关于窗口的有关问题
- alert的结果!解决方案
- 问关于GWT的东西,该怎么解决
- struts1.2.x <bean:write>标签有关问题
- tomcat5.0+sql Name sqlserver is not bound in this Context,查了好多资料都不行,大家帮帮忙啊解决方案