日期:2014-05-17 浏览次数:21205 次
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>
推荐阅读更多>
-
jdbc+sql server2005 对象名无效,该如何处理
-
请教cmpp协议中对于群发的用户数量是否有最大限制
-
Telnet 中输入流输入流有关问题
-
,转换字符串,什么时间需要用tostring(),什么时间需要new String()
-
javaEE开发,javaBean代码模拟登录各种站点解决方法
-
关于网站map的有关问题
-
java 虚拟机有关问题
-
javascript 能与浏览器进行交互么?解决方案
-
求大神,该怎么解决
-
一个比较菜的有关问题
-
如何得到鼠标点击在线图片的位置坐标
-
求这几道题的答案,再次多谢大家了!很着急多谢了!
-
一次悲剧的面试经历,该如何处理
-
JAVAscriptE框架网页访问对象,不是太懂老是出有关问题
-
关于虚拟机的,该如何解决
-
Jsoup解析HTML,初学解决思路
-
JTextField 添加 ActionListener的有关问题
-
这是在干吗
-
java编译.exe有关问题
-
ECLIPSE怎么安装Axis插件