日期:2014-05-17 浏览次数:20730 次
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>
![]()
推荐阅读更多>
- 是否都有必要设置conn.setAutoCommit(false),该如何处理
- 怎么在actionPerformed()函数中实现多线程方式
- sql取数据库中对应数据总行数解决办法
- 关于JAVA开发工具的有关问题
- 核心技术出错了,该怎么解决
- jsp链接什么时候用jsp,什么时候用do,该如何解决
- 用JSTL标签写的JSP页面为何保存数据返回页面时是乱码啊该怎么解决
- 请问一个JSP标签的有关问题
- java关于验证登陆的有关问题
- 关于执行java的批处理,该如何解决
- 几道面试题解决方案
- 哪位高手有 J2ME开发精解 的源代码,帮忙!
- 拜师,该如何解决
- 哪位高手能帮小弟我修改下BBS的jsp代码
- 能不能创建一个file实例?LINUX下的一个文件解决思路
- Oracle序列自动增长有关问题
- 登陆界面文本框提示如何搞
- 定时部署出错
- 积分?该如何解决
- JPA的JQL in查询有关问题