-->
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.  [ 2 posts ] 
Author Message
 Post subject: boolean variable is-, getter and setter methods
PostPosted: Thu Oct 21, 2010 12:12 pm 
Newbie

Joined: Thu Oct 21, 2010 10:50 am
Posts: 2
Hello.
I've been checking the forum for this problem but didn't found the same problem. Apologize in case it was already posted

This is the scenario:
I have two classes like
class A{
private boolean isMove
public boolean isMove() {
return isMove;
}
public void setMove(boolean isMove) {
this.isMove = isMove;
}
}
class B extends A
...

I persist B in a table using hibernate
<class name="B" table="tabb">
<id name="id" column="id_plan" >
<generator class="increment"/>
</id>

...
<property name="isMove" column="is_move" />
</class>

With this code, I get the following execution error:
Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

If I modify the name of the getter and setter method of A like that:
public boolean getIsMove() {
return isMove;
}
public void setIsMove(boolean isMove) {
this.isMove = isMove;
}

then everything works fine.
It is an overhead, as I cannot use anymore automatic code generation with eclipse and I would have to refactor several methods.
In the Tutorial, it is stated that Hibernate uses standard JavaBean naming conventions but isMove and setMove are standard. It is also stated that it is not mandatory to provide getters and setters, as hibernate can get access to private variables.
What is then the problem?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: boolean variable is-, getter and setter methods
PostPosted: Thu Oct 21, 2010 1:32 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You should not include the 'is' in the property name. Try this instead.

Code:
<property name="move" column="is_move" />


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