Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: sdavidr <david(dot)ricoma(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Date: 2011-03-28 08:19:44
Message-ID: AANLkTi=ae0RQSXQ8kD0=J2naP4EJw9r2-ssSouJ=PWY7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Mon, Mar 28, 2011 at 1:02 AM, sdavidr <david(dot)ricoma(at)gmail(dot)com> wrote:

> Yes, the problem is not only with version 9. The problem started with the
> "returning *", that from my perspective is a very error prone solution and
> of course it shows a poorly designed driver.
>
> The question is: is it very difficult to change that to a more correct
> returning [identifier] ?
>
> Because of this error, third parties like hibernate expects that the first
> returned element is the identifier, but that doesn't always happens.
> Sometimes it returns a discriminator, sometimes it could be something else
> that could be a long, and that could be disastrous if third party uses this
> number as a identifier in an application.
>

I've suffered from this problem for several years now. The answer was to
not use a serial column with the identity id generator type in hibernate,
since it is the id generator that adds the 'returning *' clause (I think.
It's been a long time since I looked into it. I tried to figure out how to
rewrite the hibernate sql grammar for jdbc so that it wouldn't use returning
* but gave up after wasting several hours on it). Going back to explicitly
declaring a sequence for generating the id and then using the sequence id
generator fixed the problem for me. It is slightly less efficient, but if
efficiency were your primary concern, you probably wouldn't be using
hibernate. This problem shows up in my codebase because I've got some
tables that have a common parent table, but the id columns are declared in
the child tables - so the id column isn't the first column in the table
definition. I guess that so long as you declare all tables with the id
column first, it wouldn't be a problem. I don't think it is a postgres
problem. It's a hibernate problem.

>
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Problems-with-Hibernate-Discriminators-and-9-0-801-jdbc4-tp4259788p4267176.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2011-03-28 09:05:40 Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Previous Message sdavidr 2011-03-28 08:02:44 Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4