日期:2014-05-17 浏览次数:21207 次
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>
推荐阅读更多>
-
小弟我还是个学生,想知道你们这些过来人对女java程序员的看法
-
为什么执行只是更新一条数据,帮看看,该怎么处理
-
tomcat6 打开中文资源的有关问题
-
内存和常量池的关系,请高手帮忙解惑,该怎么解决
-
奇怪的附件下传
-
点击超链接下载文件时为什么老是自动打开并且出现乱码?但是右击另存为得到的文件是正确的,这是为什么呢?请!
-
@Autowired 流入对象是NULL
-
servlet引起的有关问题
-
volatile 指令重排序有关问题
-
jsp中用js读取xml不行啊该怎么处理
-
为什么不能运行啊
-
struts2的ModelDriven是否支持多对象。解决办法
-
有关Java 程序文件相互调用类的有关问题
-
怎么重用实现类中的共用方法
-
一个实施人员的心声.再散100分.解决办法
-
struts2 中Action 接收页面以get形式传过来的参数,中文乱码?如何解决
-
简单的socket 客户端与服务器端 同一台电脑上 通信代码执行顺序,该怎么解决
-
java基础不是很好,android应该如何学
-
如何把随机数赋值到文本框里
-
项目里管理模块的有关问题