日期:2014-05-17 浏览次数:20914 次
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>
推荐阅读更多>
-
struts1.2中action的嵌套有关问题
-
冯三退一的程序 求大神找错!
-
<ns:return> <name xmlns:xsi="http://www.w3.org/2001/xmlscHEMA-INSTANCE" XSI:NIL=,该如何解决
-
控制台读取输入流,读到2个空行则停止该如何实现
-
怎么查表后生成json数据 求解答
-
求MySql建立类似于猪八戒网的威客数据库,该如何处理
-
s标签 图片src 当action 解析?解决方法
-
ftp上传有关问题,求大神指教,真的挺急
-
关于JLabel的setText在监听器中不刷新有关问题
-
求精美的jsp登陆跟注册模板
-
出家解决办法
-
一个输入两次密码就出有关问题的程序
-
JAVA接收python函数返回数据解决思路
-
请教,在关闭浏览器的时候怎样才能向服务器发出一个请求,清除session会话呢
-
java 写一个直线方程函数的困惑?该如何解决
-
用java语言编写一个打印出钻石形状的图形的程序解决方案
-
关于Sql Server数据库编码与Java编码的有关问题,多谢
-
weblogic9服务怎么定时停止和启动
-
在项目中mysql数据库访问不到,报错如上,求解决
-
请问jsp中下拉列表的有关问题