日期:2014-05-17 浏览次数:20711 次
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>
![]()
推荐阅读更多>
- 有没有相仿条码装箱检验系统的视频教程或项目
- !如何关闭session!节约服务器资源
- 怎么显示jfreechart时序图
- <html:select>标签有关问题的困扰
- 关于select跟checkbox的关联
- jsp页面里如何用Cookie
- org.springframework.beans.factory.BeanCreationException有关问题
- 关于frame frameset的一个小疑点
- <s:textfield value="<%=decodeCurrentNodeName %>" /> 出现错误
- 怎么获取在一个账号下能访问的所有URL
- 深夜求推荐【什么样的凳子桌子写代码比较舒服】
- 文件批量处理有关问题
- jsp页面重复刷新有关问题
- 初级,该怎么解决
- 【散分】总算感冒了
- 如下的需求,该如何实现呢~ 关于list中数据的拼接有关问题
- 线程控制有关问题
- 在windows中怎么java代码实现解压tar的文件
- IE和火狐对相对路径的解析不同?java web解决办法
- struts HTTP Status 500解决办法