欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

org.hibernate.propertyaccessexception: exception occurred inside getter of pack

更新时间: 2014-01-05 02:25:22 责任编辑: Author_N1

 

org.hibernate.PropertyAccessException: Exception occurred inside getter of pack.

 

报如下,异常是因为,在Person对象中.设置的属性类型不一致造成的..

请检查。对应bean中set方法数据类型和hibernate配置文件中定义的类型是否一致。

 

比如你Person中的属性id 定义的类型为Integer ,而set方法是int id.这样则会发生这样的错误.改成统一的类型即可..

 

%%%% Error Creating SessionFactory %%%%
org.hibernate.PropertyAccessException: Exception occurred inside getter of pack.java.model.Person.id
 at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:148)
 at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
 at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
 at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123)
 at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
 at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
 at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
 at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
 at pack.java.hibernate.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:30)
 at pack.java.test.HibernateDaoDemo.getSession(HibernateDaoDemo.java:30)
 at pack.java.test.HibernateDaoDemo.main(HibernateDaoDemo.java:20)
Caused by: java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:592)
 at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
 ... 11 more
Caused by: java.lang.NullPointerException
 at pack.java.model.Person.getId(Person.java:14)
 ... 16 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource pack/java/model/Address_one_to_one.hbm.xml
 at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
 at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
 at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
 at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
 at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
 at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
 at pack.java.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:68)
 at pack.java.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:52)
 at pack.java.test.HibernateDaoDemo.getSession(HibernateDaoDemo.java:30)
 at pack.java.test.HibernateDaoDemo.main(HibernateDaoDemo.java:20)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping pack.java.model.Address
 at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
 at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
 at org.hibernate.cfg.Configuration.add(Configuration.java:669)
 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
 at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
 ... 9 more

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:25:22
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/9598/
本文WWW.DOC100.NET DOC100.NET版权所有。