While running the HibernateTool hbm2ddl task for generating DDL scripts from Entity. If I have an entity with a Sequence defined like follows:
@Entity
@SequenceGenerator(name="attachment_id_seq", sequenceName="attachment_id_seq", allocationSize=25)
public class UserEntity {
@Id @GeneratedValue(generator="attachment_id_seq", strategy=GenerationType.SEQUENCE)
private int id;
private String userName;
private String password;
}
The Generated code I get is
drop table UserEntity cascade constraints;
drop sequence attachment_id_seq;
create table UserEntity (id number(10,0) not null, password varchar2(255 char), userName varchar2(255 char), primary key (id));
create sequence attachment_id_seq;
I wanted it to be something like
CREATE SEQUENCE attachment_id_seq INCREMENT BY 25;
Looks like the code in the SequenceGenerator.java at 146 (hibernate-core.jar) uses a deprecated method of Dialect.
String[] ddl = dialect.getCreateSequenceStrings(sequenceName) that returns
>>> return "create sequence " + sequenceName; //starts with 1, implicitly
We need it to return
>> return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;
|