-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Bug found in BasicPropertyAccessor.getGetter
PostPosted: Tue Jan 11, 2005 7:10 am 
Beginner
Beginner

Joined: Tue Aug 10, 2004 8:59 am
Posts: 47
Hibernate version: 2.1

I think I have identified a bug in the class BasicPropertyAccessor used by hibernate. I have a bean in which I have properties which are called names like xUnit and zIndex. Notice that the first part of the names are a single letter (x and z respectively). Hibernate is unable to find my corresponding getter methods getXUnit and getZIndex and throws the exception shown below.

I noticed that this only happened for methods which had names in which the first part consisted of only a single char, so out of curriosity I renamed my methods to getXxUnit and getZzIndex and to my surprise it now works. I checked this quite thoroughly for different properties, and it fails consistently - as soon as I use only a single letter as a part of the name, hibernate cannot find the getter.

Does anyone know if this is a known bug or if there is any better workaround?

Randahl





Caused by: net.sf.hibernate.PropertyNotFoundException: Could not find a getter f
or xUnit in class dk.rockit.puls.server.entity.website.template.StaticConstraint
s
at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicProper
tyAccessor.java:182)
at net.sf.hibernate.mapping.Property.getGetter(Property.java:175)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEnt
ityPersister.java:733)
at net.sf.hibernate.persister.NormalizedEntityPersister.<init>(Normalize
dEntityPersister.java:719)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(Pers
isterFactory.java:45)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.ja
va:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.
java:768)
at dk.rockit.puls.server.hibernate.SessionManager.initialize(SessionMana
ger.java:38)
... 74 more


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 8:32 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, you haven't found a bug, its an FAQ.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 10:32 am 
Beginner
Beginner

Joined: Tue Aug 10, 2004 8:59 am
Posts: 47
Could you please elaborate? Is there a special reason why you get this error when using names like zIndex? Should not zIndex be an allowed property name since zzIndex is an allowed name?

Thank you

Randahl


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 10:59 am 
Beginner
Beginner

Joined: Tue Aug 10, 2004 8:59 am
Posts: 47
Great, I found a work arround on this page:
http://www.hibernate.org/116.html#A33

Still, might I ask why hibernate does not support naming a property zIndex? Since this has been turned into a FAQ I am obviously not the first person to encounter this problem - would it not be a great help, if hibernate was changed to support this? And would it not be trivial to fix this?

It has been a while since I read the JavaBeans spec, but I do not recall any obvious reasons why you should not be allowed to call a bean property zIndex, and, to no surprise, doing so is accepted by the java compiler...
Randahl


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.