I have JPA annotated entity with ID defined as auto-generated property using sequences. But when I am trying to generate DDL with hibernate3-maven-plugin then my defined sequences are not generated, instead hibernate_sequence is there.

@Entity
@Table(name = "DUMMY")
@SequenceGenerator(name = "DUMMY_SEQ")
public class Dummy {
    private Long pk;

    @Id
    @Column(name = "PK", nullable = false )
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="DUMMY_SEQ")
    public Long getPk() {
        return pk;
    }

    public void setPk(Long pk) {
        this.pk = pk;
    }
}

I am expecting something like:

create sequence DUMMY_SEQ;

in generated DDL. What I am doing wrong? hibernate3-maven-plugin version is 2.2 hibernate-entitymanager version 3.4.0.GA

1

There are 1 answers

0
Mikko Maunu On BEST ANSWER

You haven't defined name of database sequence. Attribute name in SequenceGenerator is only name of the SequenceGenerator itself, not the name of the sequence in database. Result is that provider default, in this case *hibernate_sequence* is used. To affect name of the sequence, use sequenceName attribute:

@SequenceGenerator(name = "DUMMY_SEQ", sequenceName="DUMMY_SEQ")