日期:2014-05-17 浏览次数:21260 次
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>
推荐阅读更多>
-
关于非法退出如何避免
-
struts2中的上拉列表中listKey和listValue的有关问题
-
未找到 org.apache.tools.zip.ZipOutputStream 的类文件解决方案
-
"Exception in thread "main" java.lang.NoClassDefFoundError: helloworls"这是什么意思,该如何解决
-
遇到个个人没遇到过的有关问题,求告解~多谢
-
问个import 有关问题 搞了一天了
-
怎么实现3个JSP页面的传值,不用SESSION
-
j2me setRequestProperty解决办法
-
java矩阵有关问题
-
资源没了
-
struts2 对象属性流入不进去, 报错:target is null for setProperty(null, "x" [Ljava.lang.Stri
-
openoffice创建表格.该怎么处理
-
json过滤属性解决办法
-
版主测试,该怎么解决
-
J2EE的六个最佳实践
-
如和将dom4j-1.6.zip整合到MyEclipse6.0中?该怎么解决
-
NoClassDefFoundError异常
-
在JAVA版本前前迷失。该怎么处理
-
没见过的错误
-
MyEclipse外连Tomcat,项目公布到了Tomcat上,可是jsp文件不能编译成class和java源文件