日期:2014-05-17 浏览次数:21190 次
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>
推荐阅读更多>
-
怎么使用SwingWorker类来实现界面实时强制自动刷新?
-
有个程序一直报错,但不知道如何改,了
-
JTabbedPane的有关问题
-
struts 超连接的有关问题
-
关于HOTMAIL邮件发送的有关问题
-
如何获取百度贴吧提交时采用的加密因子tbs
-
依据参数设置输入焦点
-
JAVA新手的有关问题①
-
请教socket编程的有关问题
-
xhtml中的链接使用get方式传2隔以上参数解决方案
-
我的jsp页面都用gbk时正常,可是把gbk全部改为utf-8后,页面就全是乱码,(我没有用到数据库),如何回事
-
myeclipse 连接mysql 错误:java.sql.SQLException: Access denied for user 'root'@'local
-
关于Scanner中.nextLine的一些疑惑,该如何处理
-
一个比较简单的javascript有关问题
-
求高手用for循环帮帮小弟我(最好写上注释)
-
hibernate 映射sql server中的binary字段做主键解决思路
-
<>一个关于String对象的有关问题
-
关于通用分页bean的有关问题
-
oracle触发器有关问题,请高手指教
-
谁能给小弟我放一下网站?