日期:2014-05-17 浏览次数:21229 次
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>
推荐阅读更多>
-
男人可以哭吗?该怎么处理
-
Eclipse中10个最有用的快捷键组合
-
终极题!体会多态,该如何处理
-
weblogic调试web项目,debug形式正常,运行模式下报空指针
-
Exception in thread "main" java.lang.UnsupportedClassVersionError解决办法
-
大家都来看看哈!小弟我是真晕了
-
请教一个有关static变量的有关问题
-
jsp中让cookies 或session 全站共享?解决方案
-
dtree 通过从数据库的信息添加到节点信息中遇到的有关问题
-
关于数据库查询的 效率解决思路
-
请教小弟我要学jsp需要安装写什么软件?做什么样的配置才行
-
怎样监听jtable的列改变事件?该如何解决
-
请推荐书籍和方法解决办法
-
java 解析apk的AndroidManifest.xml文件获取apk起动类
-
求指点,该怎么解决
-
hibernate如何通过实体类创建数据库表
-
再问一个简单的java错误有关问题
-
java中一个类的属性几时初始化
-
jzkit2 Z3950 服务器配置(高分)
-
struts1 页面file类型在Action里的取值有关问题?