日期:2014-05-17 浏览次数:21102 次
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>
推荐阅读更多>
-
Jquery兑现复选框的左右交换
-
用strust标签怎么获取Map 具体某个键的值,就像地图.get(key)
-
请问空格输出有关问题
-
eclipse的visual editor是VE-runtime-1.2.3_jem.zip么?解决方法
-
select下拉菜单如何不能把值传入action
-
java面试题,给一组域名排序解决方案
-
java简单有关问题
-
Jstl<c:out>标签怎样输出数值,该怎么解决
-
Java 实例对象 引用的有关问题,求大侠
-
jsp中口令卡令牌操作代码兑现
-
求好手点拨:“搜索本地硬盘特定文件”的代码的书写深层理解
-
数据库数据返回json?解决办法
-
网络商店实例调试出现有关问题!望各位能指点迷津
-
这个bean有什么有关问题
-
ext toolbar 动态添加过多有关问题
-
,lucene索引大文本文件并高亮显示,内存溢出
-
JSP 多页传值?解决方案
-
Context [] startup failed due to previous errors解决方案
-
[]最近小弟在开发一个程序但出现数据库死锁有关问题
-
主键自动生成有关问题