日期:2014-05-17 浏览次数:20703 次
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 -Dfile.encoding=GBK class 中文字符串" 传入的中文string 显示部正确解决思路
- 关于dom4j处置转义字符
- jxl取值转化数值类型有关问题
- 下面的话语产生了几个对象
- 问一个关于hibernate的初学者有关问题
- j2me菜鸟的几个疑问,关于在s60下开发java程序的
- 一个简单的jsp的登录界面
- jsp有关问题,菜鸟求救
- 如何在页面动态控制一个th的属性(把一个文本框的值传给th的属性)
- SQL查询有关问题
- 怎样通过getRuntime()调用word和excel,该如何解决
- borderlayout的有关问题
- 有关使用虚拟主机后jsp文件找不到java bean的有关问题
- 一个四舍五入精度的有关问题
- 大家来谈谈,现在程序员是一个怎样的职业,有前途吗?该怎么解决
- JSON数据返回至JSP页面有关问题
- java 数据库连接的问题
- 通宵求解,诸位大神进来给点意见,关于struts标签的技术难题。跪等解决!
- webservice 赋值有关问题
- 点击个超级连接后提交相应的数据去一个页面处理,该怎么处理