日期:2014-05-17 浏览次数:21021 次
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>
推荐阅读更多>
-
怎么获取JTable的模型,然后添加一行空白行
-
关于表单重复提交的一个小疑义
-
aix +tomcat5.0.28+jdk1.42的内存有关问题
-
JSP乱码有关问题,我刚研究过的,又出现了,这次解决不了了,大家帮忙看看咋回事
-
springMVC之helloworld出现有关问题啦~帮忙看看咯
-
currentTimeMillis这个函数有有关问题吧
-
关于java访问控制符的有关问题
-
小妹推荐一套java课程
-
请教怎么在很多文章或者新闻中找到大家比较关注的呢
-
js编码是不是可以使用java的解码
-
安徽吖,大哥,该怎么解决
-
页面图片显示特效
-
怎么把.sql文件导入到MySql Control Center中
-
小细节有关问题,jsp页面里的锚点跳转有关问题
-
想做一个基于struts框架的BBS论坛解决思路
-
程序运行时总是显示有错误,求修改
-
请推荐Java用书
-
关于开发web的实时通讯系统,大家有甚么看法?解决办法
-
s2sh调整,jsp页面第一次访问可以,然而连续访问几次之后,就访问很慢,几乎不能访问,等好久没有结果
-
关于ssh的$Proxy0 cannot be cast to 报错解决办法