Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

boolean "is" method

 
andy hardy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!