日期:2014-05-17 浏览次数:21069 次
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>
推荐阅读更多>
-
oracle ide,该如何处理
-
绘制图形有关问题
-
请求解释request.setAttribute(四个参数)解决办法
-
jsp页面是utf-8的,修改了里面的内容后,再运行就报错,提示说原来的中文字符编码不对,这是咋回事
-
JAVA起动迅雷下载
-
相熟socket和tomcat的请进
-
请高手赐教!很急该怎么解决
-
JSP新手有关问题
-
Javascript排序的有关问题
-
两段jsp代码为什么运行不起来呢? 有关问题在哪
-
关于光标焦点的有关问题
-
springMVC3.0注解上传文件有关问题
-
50分请问一个有关问题,Java中static修饰的成员变量、方法、对象,执行完后会被释放吗
-
日期有关问题
-
jmail 发送的邮件 如何换行? 小弟我的源代码如下,发送邮件已经没有关问题,但是收到的邮件内容和小弟我在页面输入后传过来的不一样,输入使用了回车键换了行,可是收到的邮件没换行。为什么?请高手指教!
-
ip动态代理机制与同jvm上的一个web项目同时存在,访问会出有关问题嘛
-
poi读取Excel文件报错误
-
java spring aop做用户权限验证功能解决办法
-
得到的年不对,咋回事
-
关于金额按比例分摊的有关问题