日期:2014-05-17 浏览次数:20895 次
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>
推荐阅读更多>
-
Hibernate与连接池获取的连接各有什么不同?解决思路
-
哪位高手了解zip文件?里面最大能放多大的文件?有个数限制吗
-
获得上传文件名的例子
-
奇事!不停向文件写入元素变化了的对象,对象的值确一直没变
-
关于Java中的输入有关问题…
-
Java程序调用gcc命令的有关问题
-
李开复给面试者出的一道题解决方法
-
消除重复数目字。为什么有个0去不掉
-
【急求】如何用java打开一个word文档
-
求SOCKET的聊天室,该怎么处理
-
JBuiler中的Tomcat:8080端口被站用怎么处理
-
散分:今天过生日!该如何解决
-
?面试题目解决办法
-
javascript如何给文本框赋值
-
急求jsp版的全国省地县的三级联动菜单
-
JAVABEAN class资料应该放在哪里
-
关于DDOS攻击,求解决方案解决方案
-
一个字符串类型的变量,保存sql,执行时总是说 ORA-00911: 无效字符,为什么?解决思路
-
关于include的有关问题非用一项目 紧急高手帮忙
-
jsp怎么将一个String类型参数传递到弹出窗口