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: Hibernate getter / setter naming problem
PostPosted: Mon Dec 05, 2005 4:12 pm 
Newbie

Joined: Mon Dec 05, 2005 3:59 pm
Posts: 2
My team is applying hibernate to an existing database. We currently have java classes to map to database tables and are looking to switch the classes to use hibernate. The classes use the standard java naming convention for their gets and sets (getName, setName). However, Hibernate does not always accept the current names and seems to want the setter and getter names to be all lower case (getname, setname) for some classes and accept the current names for others.

I was wondering if there is any way to tell hibernate in the property section, or any section for that matter, to use a specified getter or setter rather than determine it on its own. It would also be nice to know why hibernate would sometimes accept the method names and sometime not.

We are using Hibernate 3.0 and PostgreSQL 8.0

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you use standard java beans namings then hibernate will pick it up.

You must give concrete examples for us to help out.


(if you just want to hack then set the accesor property to a class that conforms to your naming strategy)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2005 4:35 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hibernate is using the class:

org.hibernate.property.BasicPropertyAccessor

to access the properties. You can write your
own Property-Accessor, if you do not like
the default naming strategy.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 3:39 pm 
Newbie

Joined: Mon Dec 12, 2005 2:13 pm
Posts: 2
Location: albuquerque, nm
I am having a similar problem where the properties are named "_name" and the getters and setters are "getName" and "setName". When I run I get the following error:

------------> Initial SessionFactory creation failed. org.hibernate.PropertyNotFoundException: Could not find a getter for _epoch in class best.simulation.components.environment.atmosphere.vis_ir_radiation_transport.GetThermalRTCalcCache


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 3:40 pm 
Newbie

Joined: Mon Dec 12, 2005 2:13 pm
Posts: 2
Location: albuquerque, nm
I am having a similar problem where the properties are named "_name" and the getters and setters are "getName" and "setName". When I run I get the following error:

------------> Initial SessionFactory creation failed. org.hibernate.PropertyNotFoundException: Could not find a getter for _epoch in class best.simulation.components.environment.atmosphere.vis_ir_radiation_transport.GetThermalRTCalcCache


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 3:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if the getters and setters are getName and setName then the property name *is* "Name" - not "_name" which more look like an implementation detail.

_________________
Max
Don't forget to rate


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.