-->
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.  [ 6 posts ] 
Author Message
 Post subject: ERROR: could not find a getter
PostPosted: Fri Sep 26, 2003 11:08 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi all,

I have the mapping:

<hibernate-mapping default-cascade="none" auto-import="true">
<class name="com.im.Trail" table="trail" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">
<id name="id" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<many-to-one name="aEndTerminal" class="com.im.Ttp"/>
<many-to-one name="zEndTerminal" class="com.im.Ttp"/>
</class>
</hibernate-mapping>

and am getting the following:

net.sf.hibernate.PropertyNotFoundException: Could not find a getter for aEndTerminal in class com.im.Trail
at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:571)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:665)
at net.sf.hibernate.persister.PersisterFactory.create(PersisterFactory.java:29)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:207)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at com.im.Main.initHibernate(Main.java:42)
at com.im.Main.go(Main.java:48)
at com.im.Main.main(Main.java:35)
Exception in thread "main"

TIA,

Steve


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 11:46 am 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
You have to implement a method getAEndTerminal in class com.im.Trail.

Hibernate adds "get" to the property name of the map and changes to fist letter to uppercase.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 11:56 am 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi all,

I forgot to mention that I use the Hibernate code generator and I do get the getters and setters generated correctly.
Te problem is with the uppercase/lower case. I experimented and when the mapping attribute is all lowercase and the code generator generates the getter with the word "get" followed by attribute uppercase and the rest stay lowercase all is ok. When the attribute has a combination of uppercase and lowercase hibernate gets confused.

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I just "discovered" that hbm2java uses it's own naive method to decaptilize stuff - this should be changed to Introspector.decaptilize(name)

This will be changed, ASAP ;)


...actually it is in the CVS now ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 1:45 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi max,

Thanks for the quick fix.
Could you please tell me exactly where in CVS did you check in the code. Somehow I fail to find it.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 2:36 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
Hi guys,

Looks like we've come to a conclusion of this matter. The problem is Introspector.decapitalize()
It has a "special case" that we're hitting, quote from javadoc:

" This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone."

I've created a copy of Introspector.decapitalize inside ReflectHelper.java without the "special case" and all works like a charm.

Let me know how can I submit the fix.

Thanks,
Steve


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.