Hi,
I have a boolean field in the Java class that I want to map to a nullable
numeric column (whose value would be 0 or 1). Hibernate does not allow
primitive types to be mapped to nullable columns. I use the default
setting in Hibernate where the fields are accessed as properties, i.e. by settters and getters. So, I want to create two sets of setters and getters - one
for Hibernate and the second one for the application's internal use, like this.
Code:
private boolean foo;
....
public boolean isFoo() {
return this.foo;
}
public void setFoo(boolean foo) {
this.foo = foo;
}
public Boolean isFooObj() {
return new Boolean(this.foo);
}
public void setFooObj(Boolean fooObj) {
this.foo = fooObj.booleanValue();
}
My question is: is this workable? Are there other ways to accomplish
the same goal?
Thanks.