users@glassfish.java.net

Re: [Fwd: Use of SERIAL and BIGSERIAL w/ EJB3 and POSTGRES]

From: <glassfish_at_javadesktop.org>
Date: Mon, 06 Aug 2007 13:46:20 PDT

I believe there are still problems regarding glassfish and postgres sequences, but from memory they are all to do with using the built in/automatic support. However if you explicitly specify the sequence as in the example it works fine (at least from my experience).

My only gripe is that postgres supports manual IDs (using a sequence yourself) and automatic IDs (using SERIAL) but that glassfish code only supports the latter directly - but gets the name of the automatic sequence wrong - which causes the problems, if you let it control the sequences.

Having just looked at some of my code, the postgres handling may still be broken given the above. I can't remember the default behaviour and would need to check it. For reference, i've created my own platform file where i've changed a couple of things:

[b]*[/b] [i]shouldNativeSequenceAcquireValueAfterInsert[/i] returns false
[b]*[/b] [i]platformSpecificSequencingInitialization[/i] contents are commented out

also if you use manual row locking you need to add
[i] public String getSelectForUpdateString() {
        return " FOR UPDATE";
    }
[/i]

then use your platform file in the persistence.xml file with

[i]<property name="toplink.target-database" value="MyPostgreSQLPlatform"/>
[/i]
where the value is your class name.

When i get some time i'd like to go through the glassfish code and sort out some of the postgres issue...
[Message sent by forum member 'jsl123' (jsl123)]

http://forums.java.net/jive/thread.jspa?messageID=229704