users@glassfish.java.net

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

From: <glassfish_at_javadesktop.org>
Date: Mon, 24 Sep 2007 18:55:01 PDT

I am currently making use of Oracle 10g Release 2 and attempting to retrieve a primary key created by a trigger when data is inserted into a table. This is a common scenario with many of the legacy tables we have.

I have successfully used the following approach for new developments with an Oracle Sequence:

    @Id
    @Column(name = "CANDIDATE_ID", nullable = false)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CANDIDATE_ID_SEQUENCE")
    @SequenceGenerator(name="CANDIDATE_ID_SEQUENCE", sequenceName="CANDIDATE_ID_SEQ", allocationSize=1)
    private int candidateId;

Is possible to do something similar to the following for retrieval of the PK generated by a trigger?

    @Id
    @Column(name = "CANDIDATE_ID", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int candidateId;

Any advice would be greatly appreciated.

Regards,

Graeme.
[Message sent by forum member 'steyng' (steyng)]

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