Recently I had following problem: Hibernate used an as transient annotated getter instead of the correct one. This resulted in a ClassCastException when handling the object. A sample class is attached below. So my question is:
Is this a bad design? (To have two members which might conflict.)
Is this probably a bug in Hibernate? (I did not check the latest release yet.)
Finally I renamed the transient getter to avoid the confusion.
Code:
public class Foo {
private Double manual = 0d;
public Double getManual() {
return manual;
}
public void setManual(Double manual) {
this.manual = manual;
}
@Transient
public boolean isManual() {
return getManual() > 0;
}
}
PS: I know it is probably no good design to have such similar names and conflicting getters, I only want to have clarity for the future.