日期:2014-05-17 浏览次数:21258 次
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>
推荐阅读更多>
-
一个关于jsf中<h:commandLink>标签的有关问题
-
struts的路径配置有关问题请问。
-
J2me在JBuilder2007环境下运行出现的异常,帮忙看看
-
java中final施用场景的疑问
-
最近在设计论坛程序,在用户-角色-功能设计上有点困惑,望达人进来指点一下:),该怎么解决
-
小菜疑惑 大神
-
问个初学者有关问题
-
java来解析日志 文件有什么好的思路?解决方法
-
2013年环球最强的java相关视频集
-
J2ME其实只是个抽象的概念对吧,要干活,还得要有上层的CDC,FP,PBP的实现?而这些则要花钱问sun买的?解决方法
-
数据库中出现奇怪的事解决思路
-
请帮忙解决struts有关问题
-
散分! 开心~ 庆祝"扩充话题"升裤衩,该怎么解决
-
对于请求参数的判断有关问题
-
学了java一阵子了,但感觉现在好像不会提高了,该怎么解决
-
急怎么从jdbc查询的结果集中的数据放入到String数组中
-
字符流中read方法返回值是int,为什么输出是char?该如何解决
-
哪位高手有jsp+SqlServer的免费论坛啊
-
数据库操作解决方法
-
项目中如何样解决代码编写异常