日期:2014-05-17 浏览次数:21299 次
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>
推荐阅读更多>
-
新手关于连接SQL Server的有关问题
-
话说,小弟我想哭,哪位高手能帮帮小弟我啊
-
关于Java中的输入有关问题…
-
做出来的小GUI程序打JAR包后双击没反应解决办法
-
求教!dateFormat.parse cannot be resolved to a type,该如何处理
-
如何保证将Excel的数据导入到SQL时列的顺序不变
-
怎么用 jdk1.3 编译 hibernate3
-
关于输出的有关问题
-
用jsp+javabean+sevlet实现注册遇到有关问题
-
ibatis mysql 模糊查询,该怎么处理
-
J2EE项目错误处理
-
子类调用父类构造方法,这么写有有关问题么
-
书籍推荐,该怎么解决
-
安装mysql时出现10061异常,
-
SpringMVC做文件上传怎么在工程里找到这个图片?
-
HelloMIDlet的小疑点
-
[]关于Class文件加密和spring加载的有关问题
-
jsp页面布局解决方案
-
xml selectSingleNode方法linux上报NullPointerException
-
请赐教jspSmartUpload怎么实现多图片,分开上传~