日期:2014-05-17 浏览次数:20996 次
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>
推荐阅读更多>
-
判断是否为空,得到的值是空,但却不能判断解决方案
-
windows8如其火了,java的优势可还在
-
applicationContext.xml配置有关问题
-
删除语句有关问题
-
在种中定义另外一个类的对象数组会出错,求解
-
继承中私有变量有关问题
-
Servlet Filter 类型转化出了有关问题 大家帮忙看看
-
立地停止定时任务
-
提有关问题时能带附件吗
-
简单的MVC模式struts1.2添加hibernate3的有关问题!
-
程序调试有关问题,"找不到符号"
-
初学者问的有关问题
-
怎么解决 connection reset by peer:socket write error 有关问题?
-
辞职了,可能转JAVA方面了,没底啊该怎么解决
-
tomcat不能访问目前文件夹的文件
-
~请大家帮小弟我优化开启线程的思路~
-
关于 static 方法的引用,该如何解决
-
这个程序是简单,但是没有小弟我想要的数组最大值 这个结果,求高手帮忙改正,指点一下
-
真的是念求教!JAVA是马上被.net替代了么?JAVA的工作接不接
-
在windows中怎么java代码实现解压tar的文件