日期:2014-05-17 浏览次数:20750 次
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>
![]()
推荐阅读更多>
- 急hibernate类型映射有关问题
- struts2的标签库一定要在/WEB-INF/tags下头
- JSP 的文本与下拉列表怎么连动
- 用自己主机架设一个web服务器,别人为什么访问不了?解决思路
- XFire服务器端获取客户端参数值的有关问题
- dom4j 解析XML 中同名的节点。 多谢
- 对于j2ee项目的保护,如何防止客户随意复制
- lifeway的资料下载有些啥解决办法
- 初学者提问 数据库存入的HTML标签 怎么还原显示出来
- Form Post 测试解决方案
- URL解析有关问题
- 回复“daniel_kaka (卡卡)”关于静态块加载与类实例化有关问题
- tomcat起动不自动加载项目
- 在学习Collection中遇到的有关问题
- 请教 JTable里的单元格怎么控制显示的内容
- 问一个连接数据库的方法.解决办法
- ,求教
- java语法,该怎么处理
- 急MySQL数据库中文有关问题······
- 请大家帮看下,多谢了