users@glassfish.java.net

SequenceGenerator

From: <glassfish_at_javadesktop.org>
Date: Tue, 24 Jul 2007 12:21:41 PDT

Hi, I am trying to use the SequenceGenerator for my persistent entity classes. I have my classes working with glassfish + Hibernate, but I am trying to convert the project to just glassfish (w/ builtin toplink essentials). I am using the postgresql database and the Id's that I am trying to serialize are not SERIAL and cannot be made serial. Basically I just want to use a sequence that already works with hibernate with toplink.

The code is this:

public class MyData implements Serializable {
    
    @Id()
    @SequenceGenerator(sequenceName="oid_sequence", name="oidSequence")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="oidSequence")
    @Column(name = "my_data_oid", nullable = false)
    private Integer myDataOid;
    

I have tried the SequenceGenerator annotation on the method as well as the class (not both at the same time) and I always get a postgres exception because of a null being inserted into the ID field. I have found several pieces of information regarding this but no clear answer as to how this should work or that it doesn't work. Do I need to stick with hibernate for the persistence layer?

Thanks so much,
Your friend,
Geoff
[Message sent by forum member 'gcruscoe' (gcruscoe)]

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