Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv2El-0003lF-I1 for pgsql-jdbc@arkaria.postgresql.org; Fri, 05 Jul 2013 09:23:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Uv2El-0003NY-1d for pgsql-jdbc@arkaria.postgresql.org; Fri, 05 Jul 2013 09:23:31 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv2Ek-0003NR-24 for pgsql-jdbc@postgresql.org; Fri, 05 Jul 2013 09:23:30 +0000 Received: from prod2.officenet.no ([195.159.87.246]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv2Eg-0000hO-V5 for pgsql-jdbc@postgresql.org; Fri, 05 Jul 2013 09:23:29 +0000 Received: from localhost ([127.0.0.1] helo=prod2) by prod2.officenet.no with esmtp (Exim 4.76) (envelope-from ) id 1Uv2Cc-0005BN-AT for pgsql-jdbc@postgresql.org; Fri, 05 Jul 2013 11:21:18 +0200 Date: Fri, 5 Jul 2013 11:21:17 +0200 (CEST) From: Andreas Joseph Krogh To: pgsql-jdbc@postgresql.org Message-ID: In-Reply-To: Subject: Re: [HACKERS] JPA + enum == Exception MIME-Version: 1.0 X-Mailer: OfficeNet Mail 1.9.0-SNAPSHOT X-Pg-Spam-Score: 1.7 (+) Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org
P=C3=A5 fredag 05. juli 2013 kl. 09:51:03, skrev Tom Dunstan <pgsql@tomd.cc>:
On 9 February 2013 02:56, Kris Jurka <= ;books@ejurka.com= > wrote:
The other workaround = is to use the url parameter stringtype=3Dunspecified to
have setString always bind to unknown instead of varchar, which then
shouldn't require any code changes.
=C2=A0
I just tried this with a new project using hibernate and po= stgres with an enum type . Unfortunately, the hibernate (3.6) enum type cal= ls setObject(pos, value, Types.VARCHAR) rather than calling setString(pos, = value), and that doesn't respect the stringtype property.
=C2=A0
What's the feeling here - should setObject(Types.VARCHAR) r= espect stringtype=3Dunspecified? I don't know whether there are semantic di= fferences between setString() and setObject(Types.VARCHAR) to know if that'= s naughty or not. It seems like the only way for me to use this version of = hibernate with pgsql enums is to either change the driver or implement a cu= stom user type and configure it everywhere. :(
=C2=A0
Happy to whip up a patch if there's consensus to change the= driver.
=C2=A0
Cheers
=C2=A0
Tom
=C2=A0
I've been using Hibernate for years with mapping Enums to varchar-colu= mns which works fine. Remember to map them with
=C2=A0
@Column(name =3D "column_name")
@Enumerated(EnumType.STRING)
private MyEnum enum =3D <stuff>
=C2=A0
--
Andreas Joseph Krogh <andreak@officenet.no>=C2=A0 =C2=A0 =C2=A0 mob: = +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
=C2=A0
=