日期:2014-05-17 浏览次数:20953 次
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>
推荐阅读更多>
-
JOptionPane.showMessageDialog弹出框怎么显示JTable
-
怎么让<td>内的text控件与<td>一样大小
-
.bat文件修改xml文档时,出现了中文乱码。哪个大哥知道如何解决啊真急
-
org.apache.ibatis.type.TypeException,该如何解决
-
js el表达式取值,该如何处理
-
在JSP中怎么用JSTL的c:forEach遍历元素是Map类型的List
-
给大伙儿发一个java 自动生成Bean的工具代码
-
求jbiulder2006下载解决方案
-
ssh的项目银行项目,oracle数据库
-
初学,请问有关问题
-
寻找学生学籍管理系统的源代码,要求是让做成WEB的APPLET~解决方法
-
请教servlet如何调用winzip或winrar对服务器上的文件进行打包
-
关于错误概念的一个小疑惑
-
SQLSERVER2000数据导出到excel 用JAVA写,多谢大家
-
求大牛给一个自学方向,解决思路
-
Swing布局请问,涉及GridBagLayout
-
学完java一年刚毕业,签的公司要小弟我去数据报表组,合适
-
log4j乱码有关问题(xml配置)
-
java模拟登陆 10行代码便是不成功 求大神看看
-
java正则表达式,正则表达式截取子串