File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes boolean Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "boolean "is" method" Watch "boolean "is" method" New topic
Author

boolean "is" method

andy hardy
Greenhorn

Joined: Jul 06, 2007
Posts: 1
Hi

I have a boolean attribute e.g.

boolean isAttribute;

For some reason hibernate expects a getter for this i.e.

public boolean getIsAttribute() {
return isAttribute;
}


Id really like to just use an "is" method i.e.

public boolean isAttribute() {
return isAttribute;
}


Any ideas why there is this restriction? I'm guessing it's to do with something like hibernate using BeanUtils under the covers and thats the default pattern. Even so I;d expect this to be a recognised and preferred pattern.

Thanks
Andy
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

try just making the var

boolean attribute;

public boolean isAttribute()
{ return attribute; }

And make sure you map it as a boolean.

It should look for an is method.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: boolean "is" method
 
Threads others viewed
regex and backslash..
Default values for Hibernate POJO fields using annotations?
Boolean and boolean
Finding Numeric value from String object
Design Pattern Needed
IntelliJ Java IDE