日期:2014-05-17 浏览次数:20850 次
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>
推荐阅读更多>
-
数据库中如何计算两个日期之间的天数
-
j2me form组件能否全屏吗?该怎么处理
-
关于java import的一点疑问,该如何解决
-
老生常谈:地址栏显示图标有关问题
-
问问this的施用
-
高手,怎么用for循环创建i个对象
-
大家伙儿在spring 开发中是用注解还是用xml配置的方式
-
关于RMS中记录分类存储
-
请帮小弟我解释一下这段代码好吗
-
关于转换Double类型的有关问题
-
如何发源代码
-
何位仁兄有JDK的安装程序啊?
-
!AXIS2报Connection timed out: connect
-
jsp 自动跳转解决办法
-
问个关于SpringMVC+SpringJDBC+Velocity保存实体的有关问题,多谢
-
求人改下代码关于非静态变量的,就一两句。该如何解决
-
小弟我用struts2写的文件下传,文件30M左右,在本机tomcat下传速度很快,在服务器用weblogic9巨慢, 是从表单提交到action慢
-
JAVAWEB网站开发,一对多,多对一,主表与子表(主外键)相连接,能导致主表字段在JSP页面重复出现
-
jsp 页面标签计算 就解答
-
字符串值里包含双引号的,如何写append到字符串对象里