日期:2014-05-17 浏览次数:21106 次
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>
推荐阅读更多>
-
为什么blob字段中明明是中文取出却变乱码
-
迷茫,即将步入社会
-
北大青鸟 S1java所有课件 供学习者下载
-
启动,未初始化小程序,该如何解决
-
关于java写socket服务和c写的客户端的通信,该如何解决
-
itext 水印的有关问题
-
【今天打开程序全报错,求高手帮忙,诚谢!】解决方法
-
【向ZangXT等大侠提问】关于创建String新对象有关问题的8种情况
-
如何都搞不出来。汗了。
-
Too Many Connection怎么解决
-
想做一个FTP服务器,好手来说说思路
-
JApplet中画图有关问题
-
请教个位JNDI到底是什么意思呀,始终没有理解清楚
-
这代码为什么运行不了
-
java与数据库中int,该怎么处理
-
关于js的有关问题!希望来解答下!分不多!多谢
-
关于使用POI 把图片导入到Excel有关问题
-
怎么把从数据库中查找的图片放在另一个文件中
-
关于c3p0连接池的单例有关问题
-
怎么读取radio选定记录的某一列值