日期:2014-05-17 浏览次数:20780 次
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 web高手过来看看,该怎么解决
- 每日四十分散分贴,前四人每人十分,大家抓紧!当天结贴
- swing开发中,哪种最有效率和美观的事件处理,该如何解决
- ajax session有关问题(急)
- 转:构建可扩展的Java EE施用
- 请教用JSP这个页面效果如何实现
- JAVA运行环境有关问题
- JSP运用jxl读取excel有关问题
- 怎么实现想csdn导航菜单
- struts2流程简单有关问题(小弟我是菜鸟)
- 下面代码 SUPER指代的是什么类 ? 多谢
- 第三方支付前景怎么,值得深入吗
- java大型视频文件上传,带进度条,+视频显示有关问题.
- 在myeclipse中导入安卓源码,导错版本了,如何修改设置
- Date类是Comparable类的子类吗?Comparable类变量可以引用Date类的实例吗?该怎么解决
- socket.close()但是线程中不抛出错误?请教有些什么原因
- eclipse插件如何下载和安装
- 如何判断是不是表单传的数据,还是直接用url后跟参数
- java可不可以用来做网络游戏,该如何处理
- 生手,关于Collection删除元素