I had a class that implemented both isValue and getValue methods and hibernate seemed to randomly choose which one to use. Here's what the property from my mapping file looks like:
Code:
<property generated="never" lazy="false" name="executed" type="java.lang.Integer">
<column name="Executed">
</column>
</property>
Mapping to the following Java class:
Code:
public class Test
{
private int executed;
public Test()
{
}
public Integer getExecuted()
{
return executed;
}
public boolean isExecuted()
{
return executed == 1;
}
public void setExecuted(Integer executed)
{
this.executed = executed;
}
}
I know this shouldn't be done, but sometimes stuff like this finds it's way in to the code when a few people get their hands on a class.
Every so often Hibernate would throw a Boolean to Integer class cast exception. My question is how does hibernate choose what to use as a getter in this case? For me it seemed to choose based on the state of the system it was running on, I recently re-installed windows on an SSD and was finally getting it every time I ran the class, before that I would get the class cast exception once out of every 10 or so runs. It took me a long time to track down this bug because I couldn't reliably reproduce it until recently.
Thanks for the help.