日期:2014-05-17 浏览次数:20964 次
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>
推荐阅读更多>
-
刚放假回来,好久都没有上CSDN了,散点分给大家,不知道大家还是否记得小弟我
-
java递归求解1-5阶乘之和,该怎么处理
-
发作3x3的矩阵,数据随机产生,错在哪里啊
-
整数型去重排序,测试案例错误
-
求解答 关于java web的登录模式,该如何解决
-
问一个比较基础的有关问题,大家都来看看哦
-
JAVA 线程,主程序循环调用多线程,待
-
在浏览器中展示word,excel.ppt,pdf等各种文件
-
求jsp长文章自动分页解决方法(有源码最好)
-
Spring AOP配置死活不起作用
-
j2se中的构造方法,该如何处理
-
java loadlibrary 错误
-
大家看看 应该属于JavaScript的有关问题吧?
-
都来见见`帮忙出个注意
-
小弟我的B/S情结困惑
-
级联查询的有关问题
-
关于施用LOG4J的日志输出
-
在jsp中创建了2个iframe,想在其中一个iframe提交数据(查询),在另外一个iframe显示查询结果。应该怎样做?该怎么处理
-
Tomcat v6.0运行报错,该怎么解决
-
关于IE8上载docx的文件,会变成上载zip文件的疑问