users@glassfish.java.net

Re: [JPA] replication of entities in Java SE

From: <glassfish_at_javadesktop.org>
Date: Wed, 12 Sep 2007 04:19:33 PDT

Thanks!
This works. I have tried it this way:

@Entity
public class Node {

        @Id
        private Long id;
//...
}

and using the following xml mapping for DB1 :
================================
...
    <entity class="Node" name="Node">
        <attributes>
            <id name="id">
                <generated-value generator="SEQ_NODE" strategy="SEQUENCE"/>
                <sequence-generator name="SEQ_NODE" sequence-name="SEQ_NODE" allocation-size="1"/>
            </id>
        </attributes>
    </entity>
...
================================

The question is if this could be done the other way - to declare the @GeneratedValue on Node entity and to override it with some mapping file for DB2 instead? -

@Entity
public class Node {

        @Id
        @SequenceGenerator(name = "SEQ_NODE", sequenceName = "SEQ_NODE", allocationSize = 1)
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_NODE")
        private Long id;
//...
}

..but have no idea how to override the @GeneratedValue in xml mapping file?
Is this possible?
[Message sent by forum member 'bodrin' (bodrin)]

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