| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1496 人关注过本帖
标题:[求助]一个Hibernate问题
取消只看楼主 加入收藏
笑海
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:4934
专家分:25
注 册:2007-4-29
结帖率:0
收藏
 问题点数:0 回复次数:4 
[求助]一个Hibernate问题

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


请问我哪错了 帮忙 谢谢

搜索更多相关主题的帖子: Hibernate 
2007-05-13 08:36
笑海
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:4934
专家分:25
注 册:2007-4-29
收藏
得分:0 

应该怎么改 我还是不大清楚


兔子不吃窝边草
2007-05-13 15:35
笑海
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:4934
专家分:25
注 册:2007-4-29
收藏
得分:0 

谢谢 我先去试试吧


兔子不吃窝边草
2007-05-16 23:17
笑海
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:4934
专家分:25
注 册:2007-4-29
收藏
得分:0 
在问问 在用Hibernate3.0的时候 应该加些什么jar包

我在用3.0时候 总是报错 我想应该是少了一些包

兔子不吃窝边草
2007-05-16 23:28
笑海
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:4934
专家分:25
注 册:2007-4-29
收藏
得分:0 
已经解决 是少包啊 谢谢各位

兔子不吃窝边草
2007-05-22 22:21
快速回复:[求助]一个Hibernate问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025193 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved