Dnia Åroda, 21 marca 2012 o 05:07:43 c_h_thakar napisaÅ(a):
> stagirus,
>
> How did you solve this issue ? Did you use UserType ?
>
> Could you please send the details ?
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Re-BUGS-Mapping-Hibernate-boolean-t
> o-smallint-Postgresql-tp2855367p5582702.html Sent from the PostgreSQL - jdbc
> mailing list archive at Nabble.com.
I may give you alternative solution, I use it for different situations, but
currently I write it "by hand". It's JPA aware, not bound to hibernate. Try
this:
public class entity {
private int intAsBool;
private boolean boolValue;
@Column()
protected int getIntAsBool() {...}
protected void setIntAsBool(int val) {...}
@Transient
public boolean getBoolValue() {...}
public boolean setBoolValue() {...}
@PostLoad
protected void postLoad() {
setBoolValue(getIntAsBool() == 1);
}
@PrePersist
@PreUpdate
protected void preStore() {
setIntAsBool(getBoolValue() ? 1 : 0);
}
}
Bear in mind you need to choose only one way to mark JPA annotations field or
ancestors, 2nd one is better for many reasons.
Hope this help. I use this construct to store and map T/N char(1) values to
boolean.
Regards,
Radosław Smogura
http://softperience.eu/