日期:2014-05-17 浏览次数:20939 次
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>
推荐阅读更多>
-
调用dao.createHQuery出错Exception,错误信息:net.sf.hibernate.QueryException:
-
ssh [Ljava.lang.Object; cannot be cast to 的有关问题
-
求解释这2段代码的解决办法
-
JAVA怎么让一个窗体显示在另外一个窗体之上
-
使用ObjectInputStream这个错误异常哪位高手能帮看一下
-
ArrayList<T>f泛型类,该怎么解决
-
在命令行中使用java命令产生的异常
-
散分! 开心~ 庆祝"扩充话题"升裤衩,该怎么解决
-
求解。关于C# 图像处理方面。解决方法
-
程序员的代码量是怎么计算的?
-
网摘-java口试笔试题大汇总
-
怎么让javadoc生成的文档,不对字段排序
-
java引语疑问
-
怎么通过网页(类似php写的网页)向后台java程序提交数据
-
麻烦大家帮ping一下网站,该如何处理
-
分页查询效率为什么高?该如何解决
-
没被明显的调用或引用然而注释以后与注释前的结果却不同,请给予指点
-
EXT的 new Ext.XTemplate有关问题,
-
怎么将一个List二维数组赋给一个通过hibernnate映射来的对象
-
散分:要给自己定位,求教。JAVA/.NET/C或C++,该如何处理