日期:2014-05-17 浏览次数:20806 次
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>
推荐阅读更多>
-
关于 spring自动定时任务解决方法
-
JS方法内取的值是false,给方法传递的值却是正确的,请高手指教。解决方案
-
这三个变量实际下是一个变量
-
Netty如何传输很长的xml字符串
-
main(String args[]) 的写法的有关问题
-
eclipse插件如何下载和安装
-
一个简单的面向对象程序,不太理解,新手请问:)小弟先多谢了
-
刚学JSP 问点有关问题
-
一个初学者巅峰困惑
-
字符串中的空格转义,该怎么解决
-
页面刷新有关问题
-
求教软考取级
-
惊人: Servlet.service() for servlet [jsp] in context with path [] threw exception
-
线程共享有关问题,求前辈指教
-
初学者,空指针,邻接表
-
【java调试的实施顺序-可能你也不曾注意的细节】
-
(散100分)庆祝SSH有关问题解决,并附上解决办法
-
不好意思,问下 <result>/{1}.jsp</result> 是什么意思,小弟我没有 1.jsp文件啊
-
大家说说这个网站如何做的
-
在页面怎么动态合并相同类别的单元格