日期:2014-05-17 浏览次数:21146 次
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>
推荐阅读更多>
-
客户端用swing,服务器端用ssi框架,如何实现crud
-
SSH整合出错 Struts Problem Report?该如何处理
-
级联查询的有关问题
-
求老鸟指导!做个酒店管理系统是用swing做还是web做!
-
软件开发过程的一个小有关问题
-
java中怎么用正则表达式替换图片的地址
-
关于string的疑问,该如何解决
-
好的JSF项目突然就不能跑了解决思路
-
Hibernate懒加载有关问题
-
关于天猫tmall砸金砖活动的技术议论
-
有没有什么办法能轻易地知道什么时候该加入什么jar包?解决办法
-
面试题 !
-
提供一个超级群,捎带散分
-
oracle 中date门类数据的处理
-
if (rs.getString(三)=="管理员")这个地方为什么不能比较
-
开发一个好的JAVA程序,你认为什么最重要?该怎么处理
-
想学习java,学过C++ ,C#如何入门
-
Struts构架下如何样把一个Bean 的一个属性赋值给一个隐藏域?(待)
-
String类型转换成Date类型返回的值格式不对啊该如何解决
-
java读取word文档,高手指教!该怎么处理