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

From: pharoz <nabble(at)pharoz(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Date: 2011-12-07 15:10:25
Message-ID: 1323270625199-5055944.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

Thx all for your diagnostic, I just found a solution.

You have to create your own PostgreSQLDialect as

public class PostgreSQLDialect extends
org.hibernate.dialect.PostgreSQLDialect {
public PostgreSQLDialect() {
super();
// tells to hibernate to not use result returned by INSERT .... RETURNING
*

this.getDefaultProperties().setProperty(AvailableSettings.USE_GET_GENERATED_KEYS,
"false");
}
}

From now you have to solution :
1) let hibernate to do a "select currval ..." query, see
#getIdentitySelectString in org.hibernate.dialect.PostgreSQLDialect

2) if all of your bean have same pk name (ex: id), you can optimize insert
process by adding two methods to your custom Dialect :
@Override
public String appendIdentitySelectToInsert(String insertString) {
return insertString + " RETURNING id";
}
@Override
public boolean supportsInsertSelectIdentity() {
return true;
}

PHaroZ

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Problems-with-Hibernate-Discriminators-and-9-0-801-jdbc4-tp4259788p5055944.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Bruno Harbulot 2011-12-07 16:27:47 Re: JDBC with SSL
Previous Message Tom Lane 2011-12-07 07:25:00 Re: test git conversion