日期:2014-05-17 浏览次数:20923 次
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>
推荐阅读更多>
-
初学者问一个关于equals方法的有关问题,求指点!
-
使用jxl导出excel时抛出一个错误java.lang.IllegalStateException,请高手指导解决方法
-
返回乱码怎么办
-
怎样用Java.net.URL表示一个本地目录下的文件?解决方法
-
org.hibernate.exception.GenericJDBCException: could not insert:解决办法
-
转义符的困惑-如何就是转义不了呢,十分困惑
-
留置系统:IT攻城狮永远的痛
-
求教一个输出的有关问题
-
向javascript中可以传入session中的值吗?解决办法
-
哪位高手有JAVA的源码
-
jquery 失效有关问题
-
上传资料在线预览求思路?
-
java有关问题,求大牛们解答
-
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Unexpected token type: ERROR解决思路
-
从数据库取出字段的前100个字符如何写
-
BufferedReader的使用有关问题
-
在java运行中出现的有关问题
-
多个类中的方法构成事务,如何解决
-
急用!该如何处理
-
Java口试基础(二)