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

From pharoz
Subject Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Date
Msg-id 1323270625199-5055944.post@n5.nabble.com
Whole thread Raw
In response to Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4  (Samuel Gendler <sgendler@ideasculptor.com>)
List 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.

pgsql-jdbc by date:

Previous
From: Tom Lane
Date:
Subject: Re: test git conversion
Next
From: Bruno Harbulot
Date:
Subject: Re: JDBC with SSL