Search code examples
jpajakarta-eeopenjpa

Change default name for OPENJPA_SEQUENCE_TABLE


I'm using Sequence Generation Type. I would like to use another name for sequence generation table. OPENJPA_SEQUENCE_TABLE. How can I override the default name? I could not find a property that I can set in the persistence.xml file.


Solution

  • Well i just assume that you use annotated entity classes. For this you can define the name of the sequence generator with the @SequenceGenerator like that:

    @Entity
    @Table(name = "YOUR_TABLE")
    @SequenceGenerator(initialValue = 1,
            allocationSize = 1,
            name = "YOUR_SQUENCE_NAME",
            sequenceName = "YOUR_SQUENCE_NAME")
    public class YourTable implements java.io.Serializable {
    
        @Id
        @GeneratedValue(generator = "YOUR_SQUENCE_NAME")
        @Column(name = "ID")
        private Integer id;
    }