Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 - Mailing list pgsql-jdbc

From Samuel Gendler
Subject Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Date
Msg-id AANLkTi=ae0RQSXQ8kD0=J2naP4EJw9r2-ssSouJ=PWY7@mail.gmail.com
Whole thread Raw
In response to Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4  (sdavidr <david.ricoma@gmail.com>)
List pgsql-jdbc


On Mon, Mar 28, 2011 at 1:02 AM, sdavidr <david.ricoma@gmail.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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

pgsql-jdbc by date:

Previous
From: sdavidr
Date:
Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Next
From: Oliver Jowett
Date:
Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4