Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D2571193567 for ; Wed, 21 Mar 2012 18:11:20 -0300 (ADT) Received: from static-ip-217-118-26-141.inaddr.ip-pool.com ([217.118.26.141] helo=mail.softperience.eu) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SASoR-0006h9-8c for pgsql-jdbc@postgresql.org; Wed, 21 Mar 2012 21:11:20 +0000 Received: from radekdesktop.localnet (bvq142.neoplus.adsl.tpnet.pl [83.29.214.142]) by mail.softperience.eu (Postfix) with ESMTPA id 2C46BC0002D; Wed, 21 Mar 2012 22:10:59 +0100 (CET) From: =?utf-8?B?UmFkb3PFgmF3?= Smogura To: pgsql-jdbc@postgresql.org Cc: c_h_thakar Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) Date: Wed, 21 Mar 2012 22:10:48 +0100 Message-ID: <1904636.6EQgLgcKN2@radekdesktop> User-Agent: KMail/4.7.4 (Linux/3.1.10-gentoo-r1; KDE/4.7.4; x86_64; ; ) In-Reply-To: <1332331663379-5582702.post@n5.nabble.com> References: <4CA503A2.7010706@opencloud.com> <1286323139238-3200618.post@n5.nabble.com> <1332331663379-5582702.post@n5.nabble.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Pg-Spam-Score: -0.8 (/) X-Archive-Number: 201203/35 X-Sequence-Number: 22774 Dnia =C3=85=C2=9Broda, 21 marca 2012 o 05:07:43 c_h_thakar napisa=C3=85= =C2=82(a): > stagirus, >=20 > How did you solve this issue ? Did you use UserType ? >=20 > Could you please send the details ? >=20 >=20 > -- > View this message in context: > http://postgresql.1045698.n5.nabble.com/Re-BUGS-Mapping-Hibernate-boo= lean-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=20 currently I write it "by hand". It's JPA aware, not bound to hibernate.= Try=20 this: public class entity { =09private int intAsBool; =09private boolean boolValue; =09@Column() =09protected int getIntAsBool() {...} =09protected void setIntAsBool(int val) {...} =09@Transient =09public boolean getBoolValue() {...} =09public boolean setBoolValue() {...} =09@PostLoad =09protected void postLoad() { =09=09setBoolValue(getIntAsBool() =3D=3D 1); =09}=20 =09@PrePersist =09@PreUpdate =09protected void preStore() { =09=09setIntAsBool(getBoolValue() ? 1 : 0); =09} } Bear in mind you need to choose only one way to mark JPA annotations fi= eld or=20 ancestors, 2nd one is better for many reasons. Hope this help. I use this construct to store and map T/N char(1) value= s to=20 boolean. Regards, Rados=C5=82aw Smogura http://softperience.eu/