日期:2014-05-17 浏览次数:21103 次
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>
推荐阅读更多>
-
求关于程序员的三句半解决方法
-
什么是wap啊200分!该如何处理
-
首页包含别的模块,怎么做
-
求助解答html或者struts标签都遇到的一个有关问题,有解决办法,但谁有合理的解释
-
java线程有关问题
-
求:JQUERY表单验证的代码,并实现AJAX验证用户名 的代码解决方案
-
哪有CVS源代码?解决思路
-
已经购买了一个域名,但不知道怎么架设它?
-
java.lang.StringIndexOutOfBoundsException: String index out of range: 12
-
急HttpURLConnection无限等待的有关问题!
-
web应用程序客户端离线判断功能,该怎么处理
-
关于项目报价的有关问题。咨询
-
java多态,该如何处理
-
小疑点,求各位大神们解答
-
jsp页面不显示数据
-
【请问讨论】数据建模方面的有关问题,怎么建模?(分不够再加)
-
请问怎么在JInternalFrame最小化后,点击按钮又转变到最大化
-
一个web的应用系统要如何实现权限控制
-
jsp中下拉列表的有关问题
-
替你心醉 j2me博客