日期:2014-05-17 浏览次数:20858 次
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>
推荐阅读更多>
-
!请教小弟我的下载地址要如何写!
-
什么是一名合格的j2ee程序员解决方法
-
struts 怎么把从数据库查出来的数据保存在本地
-
为什么跑不起来.小弟我就是想画个圈啊源码献下
-
一段static量被屡次初始化的代码(很奇怪)
-
简单且根基的有关问题:JSP、ASP 都不是语言,而是一种技术,是这样吗?多谢大家
-
TOMCAT支持J2EE版本有关问题
-
给为大神:有没有前台解析不规则的html文件,解析为规则的xhtml的库或者方法
-
java生手求教
-
Java 对外接口开发要求?该如何处理
-
jsp,getParameter为什么取不到数据?解决方案
-
怎的让Action不显示参数
-
动态实现Select?解决思路
-
<include file="top.htm" ->的有关问题
-
一个错误 exception
-
怎么在struts-config.xml文件中定义变量
-
马兵士老师JAVAEE struts2视频项目源代码
-
struts,webwork,spring的mvc在市场的占有率是多少?解决办法
-
java字体,该如何解决
-
求高手帮忙解决思路