日期:2014-05-17 浏览次数:20940 次
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>
推荐阅读更多>
-
为什么用桥连接会出现空格解决思路
-
JAVA P2P实现即时通信的思路解决方法
-
xhtml换行的有关问题
-
jfreechart曲线图X轴显示格式有关问题!
-
关于win7上的word转换成pdf有关问题,求高手解答
-
json动态赋值有关问题
-
一个学习中发现的有关问题,请明白人来解答
-
求解:关于从MySQL中查询日期 格式化有关问题
-
窗口关闭事件高手赐教,该如何解决
-
ssh学生购书系统,该如何处理
-
javamail smtp邮件发送错误
-
聘JAVA开发人员,上海解决思路
-
高手给详解一下DB2的优缺点!解决思路
-
,Schema中定义数值对
-
请问java解密时的乱码有关问题
-
请问一上关于数据权限的有关问题
-
新手问开发工具之选择,该怎么处理
-
求分页的代码解决方法
-
跪求URL转发 域名解析的有关问题
-
BigDecimal divide(BigDecimal divisor, int scale, int roundingMode) 方法解决方法