users@glassfish.java.net

V2 Beta 3, Toplink doesn't use sequence specified

From: <glassfish_at_javadesktop.org>
Date: Tue, 10 Jul 2007 16:54:33 PDT

I just tried the latest V2 Beta 3 b50g, but the Toplink doesn't seem to use the given sequence.

@Entity
@Table(name = "AMS_NODE")
@SequenceGenerator(name="seg_node_id_gen", sequenceName = "SEQ_NODE_ID")
public class Node implements Serializable {
    @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seg_node_id_gen")
    @Column(name = "NODE_ID", length =38)
    private Long mId;

   .... Rest of the code

}



And the I simply call in a helper class.
            mEntityManager.persist(node);
            mEntityManager.flush();

The the helper class is called from a stateless SessionBean which passed the injected EntityManager to helper class.

The toplink persist the node but the Id is not the number from sequence value (which starts at 5000) where the value from toplink is 4951 (which I have no idea where it comes from).

Rerun the call, multiple times, that top link will generate Id with 4952, ...., eventually it will come to the 4951 etc. again. causing PK constraint error.

Any seeing this problem before ?

Thanks
[Message sent by forum member 'chesterxgchen123' (chesterxgchen123)]

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