日期:2014-05-17 浏览次数:21068 次
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>
推荐阅读更多>
-
求推荐一本从入门到深入的SSH技术方面的读物
-
HQL模糊查询后头的 and 条件不起作用
-
dorado有哪位高手用过啊
-
javax.mail发送邮件有关问题
-
几个基础有关问题
-
jsp运行出错请各位指点一下解决思路
-
iReport1.3.3中输出PDF后粗体效果与斜体效果丢失如何解决
-
第一个 Servlet解决方法
-
为啥这段代码会发生java.lang.ClassNotFoundException:
-
怎么将整型转化为字节型
-
求大神帮忙啊毕设中的有关问题。求。
-
您会这样做吗
-
请教“海量系统”如何翻译
-
问个用JAVA(POI)把HTML导出WORD的有关问题
-
比较入门的有关问题
-
请问个有关问题。在svn上现在的ofbiz工程。在eclipse下运行build.xml文件报错,是什么原因啊如何修改
-
hibernate级联保存.该怎么处理
-
JSON有关问题
-
双击jar包,命令行窗口一闪而过,怎么能保持住
-
强烈推荐 (x.compareTo(y)==0) == (x.equals(y)) 这种做法解决方法