日期:2014-05-17 浏览次数:20912 次
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>
推荐阅读更多>
-
怎么去掉下载安全提示
-
flash与jsp结合的安全有关问题
-
JDT Core patch for Groovy-Eclipse plugin 在哪里下载啊解决办法
-
今天面试的时候被问到正则表达式引擎是如何实现的
-
请问 这个txt文件 怎么写
-
java语言在linux系统中雅量文件的存储结构算法
-
QueryRunner.update抛出错误,麻烦大侠帮忙分析一下呀
-
Myeclipse突然有有关问题了
-
这个电脑配置,叫苦不迭。
-
ssh2框架单用户登录,该怎么解决
-
64位ODBC联接Sybase数据库报错
-
structs,jsf,spring等构架
-
Java中怎么实现密码忘记的功能
-
在GUI中怎么实现格子做背景
-
method failed; nested exception is org.hibernate.HibernateException:
-
java web解决思路
-
关于struts<html:radio>里嵌套struts标签有关问题
-
请教:return type for the method is missing 是什么东东或
-
J2ME上的点阵字实现
-
用一个url进行sso登陆并访问指定的页面,但是会出现登陆失败的原因