日期:2014-05-17 浏览次数:21121 次
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>
推荐阅读更多>
-
问几个Object转换到String的有关问题
-
输出流的一些困惑,有代码
-
登录成功后怎么将用户输入的id传到下一个界面,然后根据id从数据库调处此id的其他信息
-
tomcat启动404,解决就给分解决方案
-
spring诠释方式事务管理不生效,请各位帮忙看看
-
高端大气上档次BUG->Action 里 Service 偶现空指针异常
-
老实说,大家写的简历中,工作经验部分都如实反映吗,假如有出入,不怕被查吗解决思路
-
java默认的字符编码是unicode吗?怎样把utf-8编码转为unicode编码?该怎么处理
-
写代码不知道从哪里下手?该怎么处理
-
JDBC 入门有关问题
-
一个有关问题
-
如何样才能往TimerTask类里面传送变量值呢,附部分程序供品鉴
-
web 项目中 发送邮件的有关问题,希望能懂的人帮小弟我解答一下,多谢
-
acm java输入两个数,中间用空格格开,怎么再把它门分别取出来
-
jsp怎么从servlet取值
-
服务版的tomcat7怎么调参数,Jprofiler怎么测试是否内存溢出
-
进来就有分哦解决办法
-
利用程序报错替条件来执行下一步程序这个设想不知道能否实现
-
jsp中文路径有关问题
-
帮忙看上这个异常