日期:2014-05-17 浏览次数:21019 次
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>
推荐阅读更多>
-
显示格式解决思路
-
求这段代码
-
java2Me的学习,该怎么处理
-
哪位高手能帮忙注释一下这个js程序的功能?最好每一句都解释一下
-
关于TOMCAT发布的有关问题 请求高手指导(急)
-
这个sql查询语句,转为HQL语句,如何写
-
lucene 报错,该怎么解决
-
输入输出流,循环有关问题
-
用户权限-解决方法
-
关于jsf中selectManyCheckbox的有关问题,多谢大家了
-
在游戏界面中,小弟我要调用其他的界面(比如商城),但是游戏界面并不销毁。应该如何做呢
-
帮忙看看,为什么小弟我这个文件复制程序,会无限循环复制。而且只能复制英文字符。中文一复制就乱码。
-
很奇怪的一个方法?该怎么解决
-
如何在网页中,点击修改按钮后弹出小窗体
-
奇怪的异常
-
如果有下拉框,这么样减少访问数据库的次数,该怎么处理
-
!初始化二维数组 由键盘输入
-
关于tomcat的暖部署
-
多线程对同一串口读写 如何解决
-
高校至今的总结