日期:2014-05-17 浏览次数:20786 次
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二维码换行=========================================解决办法
- (活动)社区银行新活动 图书低价限时换购,该怎么处理
- Java ,大神帮忙~知道类名和方法名,得到返回值
- 把类解析成xml解决办法
- ZK 中文论坛开张,欢迎大伙前往捧场
- 急对Calendar的应用
- 哪位高手了解webservice
- Java replaceAll方法,怎么写正则
- C++中字符串I/O,该怎么处理
- java可以像C#那样实现 using么?解决思路
- JSplitPane有关问题
- new 一个 Date,用 eclipse 输出,如何有异常呢
- 这个小程序如何编译不了
- 冒泡程序(小弟我用的是1.6的)
- <s:property>取不出Action里属性值,该怎么解决
- 用url打印特定网页的源代码出有关问题
- 子类怎么使用spring完成父类的初始化
- jsp中关于时间显示的有关问题
- xpath有读取xml文本内容 或者 属性值的功能吗 不带XML文档标签 纯文本,该如何解决
- hibernate外键取值有关问题