日期:2014-05-17 浏览次数:20815 次
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怎么调用exe文件
-
求SCJP复习资料 电子版.最好是chm,能拷贝解决方案
-
继承内部类的有关问题
-
本人看不懂网上代码,求java开发的“记事簿项目”视频教程
-
tomcat 和iis解决方案
-
求j2ee7层架构关系图-用解决办法
-
scjp(310-035)是否要淘汰了啊~~
-
在种中定义另外一个类的对象数组会出错,求解
-
有关jsoup请求页面有关问题
-
一段JAVA代码,不太明白其中的含义,请大家帮帮忙,该如何解决
-
jsp页面 hidden字段安全有关问题
-
struts2<s:iterator value="">标签的困惑,该怎么解决
-
java里有没有让出处理器的语句,该怎么解决
-
poi 平添图片 原有图片消失
-
大神看过来,ajax调用Action有关问题,不能走回调函数。贴出代码给看看是哪儿的有关问题
-
纠结啊该怎么处理
-
java编程,该如何处理
-
大神批量添加的有关问题
-
httpclient怎么完整抓取php动态加载网页
-
字符串转数值,泛型类型转换有关问题