日期:2014-05-17 浏览次数:21259 次
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>
推荐阅读更多>
-
有两道题大伙儿帮忙
-
提问: web中singleton的范围,spring中singleton的范围,该如何处理
-
ConcurrentHashMap可以取代HashMap吗解决办法
-
小弟我是Java菜鸟,想达人,你们帮帮小弟我啊
-
Spring3.1+Hibernate4.1.4有关问题
-
对职业的不解(男,89年,一年工作经验,专科)
-
错误如下:严重: Exception starting filter struts2Filter
-
java传参到底是传值还是传引用?该如何解决
-
如何通过本表的字段去查其他表的字段,注意、是通过字段
-
java代码怎的实现用户操作日志写入oracle数据库,不用log4j
-
Java web 连接数据库实现注册写到表中,该怎么处理
-
hibernate对象写入有关问题
-
transient诠注没有生效
-
用java调用wmi。哪位高手会T_T
-
JSP显示标题前10个字后面的是.如何弄
-
求大神写个jsp动态下拉菜单解决思路
-
?动态打印列表数据?该怎么解决
-
document.form.submit()为什么出错?解决思路
-
Is it OK to record?该如何处理
-
javascript动态生成有ID的,ID为变量,如何获取ID的对象