日期:2014-05-17 浏览次数:21032 次
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>
推荐阅读更多>
-
HTML里如何调用JS代码?
-
日历控件 js脚本的有关问题
-
结业季,最终还是流泪了。相信青春不会散场(散分)
-
请教在jsp中如何样用replace把\n替换成 <br>
-
能否设置eclipse在不同的workspace下开启或禁用某些插件?解决方法
-
java中的邮件应用程序有关问题
-
java out of memory heap space 异常
-
计算出来的 线程数 是0 ,所以没有执行 文件上载,哪位高手帮忙看上哪点计算有误?多谢了。
-
关于AJAX的使用有关问题
-
java网络编程有关问题2
-
新手分享一个JS有关问题
-
那位老兄有jsp+servlet+bean的博客源码
-
请帮忙建一个struts2.0的helloworld的jsp网页解决思路
-
为什么在java.sql里没有BaseQuery,小弟我用的是JDK 1.6
-
请大家指导一下,看看这个是考的什么,该怎么解决
-
老有关问题,poi导出大量数据,请大家来分析分析小弟我的测试
-
fusioncharts柱状图Y轴怎么显示百分比
-
hibernate查询的有关问题 java2000_net
-
这几个jar是免费的吗?该怎么解决
-
org.apache.catalina.LifecycleException Caused by: java.lang.NoClassDefFoundErro,该如何解决