日期:2014-05-17 浏览次数:20967 次
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>
推荐阅读更多>
-
缺少返回语句 【新手请问,请帮忙~】
-
java系QQ群81273389,该如何处理
-
到response.reset()哪里就过不去了,麻烦啊!
-
业务逻辑写在SQL里,仍是在JAVA文件中处理
-
java面试题(一)
-
效率与简要书写之争,求解释
-
was内存上涨有关问题
-
大家平时用到ATG么(Art Technology Group),该怎么解决
-
Java Eclipse 的使用请问
-
菜鸟,求help
-
至于用批处理来启动jar文件,批处理中带有参数!请知道的指点
-
取去boolean值在radio如何显示
-
老题了,一直不理解:String s = "a" + "b" + "c" + "d" + "e"一共创建了几个对象?解决方法
-
各位大侠能不能帮帮小弟 检查一下,该怎么处理
-
java之基本类型有关问题知识点
-
关于ajaxanywhere出错的有关问题
-
mybatis+spring,加入mybatis的拦截器就会报NullPointerException,该如何解决
-
“Java接口”的多重继承有关问题
-
三道面试题
-
Socket编程时,出现的一个错误!请大侠们帮帮忙!