users@glassfish.java.net

Re: JPA – Toplink Essentials - Retrieving PK populated by an Oracle Trigger

From: <glassfish_at_javadesktop.org>
Date: Tue, 25 Sep 2007 12:26:25 PDT

TopLink 10 supports returning of the generated in the db value, this functionality will also be available in TopLink 11 JPA (instead of using sequencing, setup ReturningPolicy SessionCustomizer or DescriptorCustomizer).
Unfortunately there is no clean way to do that in TopLink Essentials.

All that could be done is to override OraclePlatform class to support returning the generated value - but the altered platform will no longer support the original functionality:

[code]
public class OraclePlatformWithReturning extends OraclePlatform {
    public ValueReadQuery buildSelectQueryForNativeSequence(String seqName, Integer size) {
        return new ValueReadQuery("SELECT " + getQualifiedSequenceName(seqName) + ".CURRVAL FROM DUAL");
    }
    public boolean shouldNativeSequenceAcquireValueAfterInsert() {
        return true;
    }
}
[/code]
You can keep the original annotations - no need to switch to Identity.
[Message sent by forum member 'ailitche' (ailitche)]

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