日期:2014-05-17 浏览次数:20715 次
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>
![]()
推荐阅读更多>
- org.xml.sax.SAXParseException: org.apache.crimson.parser/P-067
- J2ME参照文档
- 请教一下,怎么从properties文件中读取日文字符正确显示在JSP页面上
- java中传输完文件以后,再传输数据就会出现有关问题么
- ★关于排序的有关问题★
- eclipse导包后,在工程目录上的lib里没有刚导入的jar
- 关于浮点数型加减的有关问题
- struts2 visitor 校验器具体怎么使用呢
- servlet的最大用途解决思路
- DOM4J 如何添加一段Nodelist
- IT行业混得最差的程序员,该怎么处理
- JPopupMenu弹出后不消失了,该如何处理
- cs改成bs模式,一般的思路是如何样呢
- 请问jsp加sql语句的有关问题,先谢了
- struts2关于接收参数String转成float类型有关问题,求高手解救
- 查找发贴最多的用户,用HQL如何写啊一个下午了写不出啊
- Java/J2EE中文有关问题终极解决之道(转)
- vector函数如何定义
- BigDecimal 的运用
- Cannot create a session after the response has been committed解决思路