日期:2014-05-17 浏览次数:20986 次
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>
推荐阅读更多>
-
关于回帖给那些结贴率很低的人主意
-
各位大拿,帮小虾一个忙?该怎么解决
-
哪位高手有jquery validate.js
-
高分乞援 ~网站模块可移动
-
形参类型是 int ,按理只能接受 数值 或 char ,为什么下面传和个 String 也行?解决办法
-
java 的synchronized有关问题
-
求Tomcat配置多个工程方案解决方案
-
2010年三月 深圳中软资源技术服务有限公司JAVA面试题目
-
大家帮小弟我看下这代码最后运行时如何不进行加法运算
-
什么打印出来的结果是这个呢
-
struts怎么接收不确定数量的参数
-
一个团购的页面中的动态信息怎么存储
-
BodyPart.setFileName()方法的使用,该如何处理
-
寻好的数据库脚本管理方案
-
小弟我通过网上接一个人项目,发现他是骗子,有证据,小弟我该怎么处理
-
大家有没有什么不错的JSP的案例的那种书啊,推荐一本咯,谢谢谢谢:)
-
问2个有关问题,散分
-
在java中如何把ascii 字符放在小框框中.也就是下面程序的每一个小框子中
-
委实不明白为什么运行不了,求解答
-
在项目管理中,大家都用什么来进行bug/defect管理和跟踪?200分解决办法