科目一模拟考试答题:Hibernate的问题.!!!!!!!!!!!!!!!!!!!!!!!!!!

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 07:39:02
我的映射文件:
<hibernate-mapping>
<class name="com.hibernate.zhcw.admin.bean.Cm01" table="CM01">
<id name="cma001" type="int" column="CMA001">
<generator class="sequence">
<param name="sequence">seq_cm01_cma001</param>
</generator>
</id>
<property name="cma011" type="int" column="CMA011" />
<property name="cma012" type="int" column="CMA012" />
<property name="cma013" type="int" column="CMA013" />
<property name="cma014" type="int" column="CMA014" />
</class>
</hibernate-mapping>
我的代码:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Query query = session.createQuery("select cm01 from Cm01 as cm01");
Iterator i = query.iterate();
while (i.hasNext()) {
Cm01 cm01 = (Cm01) i.next();
System.out.println(cm01.getCma002());
}

在这里还有一个javabean对应映射文件 。 其中cma011,cma012,cma013,cma014 都是int型的
可是数据库里的数据有为null的。在执行上面的代码的时候报错:
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.hibernate.zhcw.admin.bean.Cm01.setCma013StandardWrapperValve[debugjsp]: Servlet.service() for servlet debugjsp threw exception