日期:2014-05-17 浏览次数:21071 次
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>
推荐阅读更多>
-
网站子目录绑定域名解决方案
-
请教上面的正则过滤XML.send的内容时什么位置导至发送的内容为空
-
关于iframe页面的跳转有关问题
-
|javamy|.NET的const readonly在java中是不是以final代替,有示例代码 多谢
-
单承袭多现实的例外
-
Java String常量池在什么位置?解决方案
-
打印预览后关闭网页的有关问题
-
关于字节流的写入与读取解决方案
-
,快马加鞭
-
jspsmartupload上传下载的目录必须是绝对目录么,该怎么解决
-
调整ssh使用hibernateTemplate的find方法报空指针
-
在浏览器进去struts2的action 报错404
-
请问com.jspsmart.upload.SmartUploadException
-
为死难者默哀 散分贴2解决办法
-
100 分,三个JAVA对SQL操作的有关问题(批量导入,导出,输出报表)
-
怎么用 jdk1.3 编译 hibernate3
-
面板怎么加背景图片或者说哪个容器能有背景图片
-
小程序,不知道那里错了。解决方案
-
eclipse3.4中怎么使用hibernatetools
-
java中结构函数的执行过程