Java House

Art is long
posts - 41, comments - 74, trackbacks - 0, articles - 3
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理
在hibernate中用数据关联时,不管是一对一,一对多,还是多对多时,我写出来的程序怎么总是下面此类的错误呀,有那位朋友知道的,希望能给我解决一下,谢谢!
Exception in thread "main" org.hibernate.PropertyNotFoundException: Could not find a getter for tPassport in class org.qin.onetoone.TUser
 at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
 at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
 at org.hibernate.mapping.Property.getGetter(Property.java:260)
 at org.hibernate.tuple.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:255)
 at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:121)
 at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
 at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
 at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
 at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
 at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
 at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
 at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
 at org.qin.uniqueFKonetoone.TUserOprate.<init>(TUserOprate.java:12)
 at org.qin.uniqueFKonetoone.TUserTest.main(TUserTest.java:12)

评论

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-08-27 17:15 by ∪∩BUG
没有get方法,加上试试..

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-08-27 19:22 by qin
可还是不行

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-08-27 19:28 by ∪∩BUG
给你一篇我收藏的吧:
http://blog.csdn.net/quxiuer/archive/2008/04/26/2332761.aspx

学习是这样子的:简单的错误往往导致疲惫的调试.

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-08-28 18:28 by qin
@∪∩BUG
谢谢你哈!!的确,我都调了好多天了,都没信心了

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-08-29 12:58 by 隔叶黄莺
真的,这个问题还是很典型,这是有关于 JavaBean 规范和 IDE 的 Bug 之间的问题。
如果要吸取教训的话就不要使用首字母小写次字母大写的属性,否则自动生成的 getter/setter 方法是有问题的

tPassport,IDE 生成的 getter/setter 分别为 getTPassport()/setTPassport(),而从 JavaBean 规范及 Hibernate 的要求来讲应该是 gettPassport()/settPassport()

# re: Exception in thread "main" org.hibernate.PropertyNotFoundException错误  回复  更多评论   

2008-09-04 22:01 by xcp
哈哈,我昨天也遇到这个问题当时是uName,结果就报这个错了,后来才发现在这些属性的写法上也还要遵守一个规范才得行(不要使用首字母小写次字母大写的属性).

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-08-29 14:18 编辑过
 
 

相关链接:
网站导航: