pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreak@officenet.no>
To: pgsql-jdbc@postgresql.org
Subject: Re: [HACKERS] JPA + enum == Exception
Date: Fri, 5 Jul 2013 11:21:17 +0200 (CEST)
Message-ID: <OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2> (raw)
In-Reply-To: <CAPPfruw2cBztp+k6NTFVGHQL2JweoVYY8JTBoXHEVFMsQKT_Lg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

<div>På fredag 05. juli 2013 kl. 09:51:03, skrev Tom Dunstan &lt;<a href="mailto:pgsql@tomd.cc" target="_blank">pgsql@tomd.cc</a>&gt;:</div>

<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">On 9 February 2013 02:56, Kris Jurka <span dir="ltr">&lt;<a href="mailto:books@ejurka.com" target="_blank">books@ejurka.com</a>&gt;</span> wrote:

<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><span style="color:rgb(34,34,34)">The other workaround is to use the url parameter stringtype=unspecified to</span></div>
have setString always bind to unknown instead of varchar, which then<br>
shouldn't require any code changes.</blockquote>

<div> </div>

<div style="">I just tried this with a new project using hibernate and postgres with an enum type . Unfortunately, the hibernate (3.6) enum type calls setObject(pos, value, Types.VARCHAR) rather than calling setString(pos, value), and that doesn't respect the stringtype property.</div>

<div style=""> </div>

<div style="">What's the feeling here - should setObject(Types.VARCHAR) respect stringtype=unspecified? I don't know whether there are semantic differences 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 custom user type and configure it everywhere. :(</div>

<div style=""> </div>

<div style="">Happy to whip up a patch if there's consensus to change the driver.</div>

<div style=""> </div>

<div style="">Cheers</div>

<div style=""> </div>

<div style="">Tom</div>
</div>
</div>
</div>
</blockquote>

<div> </div>

<div>I've been using Hibernate for years with mapping Enums to varchar-columns which works fine. Remember to map them with</div>

<div> </div>

<div>@Column(name = &quot;column_name&quot;)</div>

<div>@Enumerated(EnumType.STRING)</div>

<div>private MyEnum enum = &lt;stuff&gt;</div>

<div> </div>

<div class="origo-email-signature">--<br>
Andreas Joseph Krogh &lt;andreak@officenet.no&gt;      mob: +47 909 56 963<br>
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no<br;
Public key: http://home.officenet.no/~andreak/public_key.asc</div;

<div> </div>


view thread (21+ messages)  latest in thread

Message-ID: <OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2>
Permalink:  ../OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2/
Also on:    postgresql.org/message-id/OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: andreak@officenet.no
  Subject: Re: [HACKERS] JPA + enum == Exception
  In-Reply-To: <OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2>
  References: <CAPPfruw2cBztp+k6NTFVGHQL2JweoVYY8JTBoXHEVFMsQKT_Lg@mail.gmail.com> <OrigoEmail.925.90efc08f02ee47a3.13fae200537@prod2>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox