日期:2014-05-17 浏览次数:20572 次
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.reveng.xml的作用什么解决方案
- 怎么不用遍历的方式取出二维数组中的给定val的对应Key
- jsp或者servlet,如何判断返回给clinet的response是成功的
- 关于 java 数据类型的转换的有关问题, 将 object 转换成 date
- 关于获取数据有关问题,大姐帮忙看看,多谢
- 冒泡排序有关问题:求指出异常和解决方法!
- 找个人帮帮小弟我看看这个JSP文件的异常~
- 关于maven筹建环境
- JDT Core patch for Groovy-Eclipse plugin 在哪里下载啊解决办法
- JSP中怎样实现光棒效果呀!该怎么处理
- 轮换自定义变量内容的方法-求高手
- 怎么判断上传文件类型
- javaweb 图形控件 曲线拖动,该如何处理
- java 算法题,该怎么解决
- 关于桌面应用到Web应用的单点登录,用尽所有可用分解决方法
- 怎么在Java程序中用*输出一个菱形的有关问题
- 关于JTextArea监听的有关问题
- action返回,该怎么处理
- Java经典文件免费分享[2013-04-23]
- struts+tomcat的404有关问题