usr.hbm.xml
<hibernate-mapping>
<class name="com.po.Usr" table="usr">
<id name="id" type="long">
<column name="id" />
<generator class="increment" />
</id>
<property name="name" type="string">
<column name="name" length="8" />
</property>
<property name="passwor" type="string">
<column name="passwor" length="8" />
</property>
<property name="phone" type="string">
<column name="phone" length="8" />
</property>
<property name="deptid" type="long">
<column name="deptid" />
</property>
<property name="address" type="string">
<column name="address" length="32" />
</property>
<property name="title" type="string">
<column name="title" length="16" />
</property>
<property name="power" type="string">
<column name="power" length="16" />
</property>
<property name="auth" type="string">
<column name="auth" length="16" />
</property>
<property name="homephone" type="string">
<column name="homephone" length="8" />
</property>
<property name="superauth" type="string">
<column name="superauth" length="4" />
</property>
<property name="groupid" type="long">
<column name="groupid" />
</property>
<property name="birthdate" type="date">
<column name="birthdate" length="10" />
</property>
<property name="male" type="string">
<column name="male" length="4" />
</property>
<property name="email" type="string">
<column name="email" length="128" />
</property>
</class>
</hibernate-mapping>
我的调用程序
import java.util.Iterator;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.po.*;
public class manager {
public void getList(){
Session session = null;
HibSession hib = new HibSession();
try{
session = hib.getSession();
Query query = session.createQuery("from Usr where id=36047");
List list = query.list();
Iterator it = list.iterator();
while(it.hasNext()){
Usr usr = (Usr) it.next();
System.out.println("name=="+usr.getName());
}
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
manager ma = new manager();
ma.getList();
我的异常
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.po.Usr.setGroupid
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.bo.manager.getList(manager.java:20)
at com.bo.manager.main(manager.java:34)
Caused by: net.sf.cglib.beans.BulkBeanException
at com.po.Usr$$BulkBeanByCGLIB$$499efc80.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 14 more
Caused by: java.lang.NullPointerException
... 16 more
请问我哪错了 帮忙 谢谢