日期:2014-05-17 浏览次数:20859 次
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>
推荐阅读更多>
-
请问可以对response返回的json进行压缩吗
-
"java.sql.SQLException: ORA-03115: 不支持的网络数据类型或表示法"
-
file.separator实现什么功能哇?该怎么处理
-
呃呵呵呵呵
-
webService生成服务端以后,启动报错
-
include.inc是什么文件解决方案
-
处女作 求支持,该怎么解决
-
批量创建ftp用户,该怎么解决
-
关于js调取<s:property>标签value值的有关问题,在线急等
-
string截取有关问题,求大神指教
-
[]一个线程wait()以后,如果同一对象没有其他线程还能唤醒吗
-
JSP POST传参(乱码) 为何是ISO8859_1解决办法
-
flash 读取 servlet 生成的xml 展示 undefined
-
serverlet session 的有关问题,神奇至极啊,CDSN无能人乎?
-
单例模式中关于线程同步有关问题,先谢了
-
can bind a LONG value only for insert into a LONG column解决方法
-
一段逻辑性很强的脚本语言,该怎么解决
-
TIBCO EMS与Spring集成,该如何处理
-
能编译 能运行 但是运算结果不对,不知道算法那儿出有关问题了?求,多谢
-
<j2me开发大全》那有下载?解决方案