-->
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: getter property without "get" prepended
PostPosted: Wed May 24, 2006 4:57 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:02 pm
Posts: 23
Hi,

I have a property called isActive in one of my POJOs. The setter is called setIsActive() while the getter is called isActive(). When I boot up Hibernate, I get a "org.hibernate.PropertyNotFoundException: Could not find a getter for isActive..." exception. Is there a way to let hibernate know that my isActive() method should be the getter? I can't change or edit this POJO since its interface/implementation is already set. Thanks in advance.

-los


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 5:25 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Create accessor class that will know your specific and use it
<property name="isActive" access="ClassName" ...

http://www.hibernate.org/hib_docs/v3/re ... n-property

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 11:08 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
isActive follows normal bean-method naming rules, and hibernate will handle it just fine. Use "Active" as your property name (not "isActive"), and rename your setter to "setActive". When boolean properties are being converted to method names, "is<property>" is tried before "get<property>", so it's actually marginally better to use "isActive" as your method name.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 1:46 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
requestor said:
Quote:
I can't change or edit this POJO since its interface/implementation is already set.


Therefore simple solution will not work :(

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 2:40 am 
Regular
Regular

Joined: Wed Mar 08, 2006 2:07 am
Posts: 50
Location: Bangalore
Moraleslos,
I feel what you can do is use :
<property name="active" ... access="field" />

but in case there is not property named active ... what u can do is write a private method :


Code:
private void setActive(boolean val)
{ .. }


This way you can add a new method and as no-one else except hibernate
can access it so I guess it wont break the contract of your implementation.

_________________
Prashant Jain

... right now I am in need of some credits !


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 8:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
access="YouOwnImplOfPropertyAccessor"

_________________
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.