Chetan created Bug HHH-8008
Issue Type: Bug Bug
Affects Versions: 3.6.10
Assignee: Unassigned
Components: core
Created: 15/Feb/13 12:05 AM
Description:

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 start with x 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;

We tested it for H2, Postgre and Oracle 11g. It did not generate the SQL for H2 it generated the minimum SQL for PostGre and Oracle 11g.

I have also raised another ticket at Hibernate Tools HBX-1217. But since I was told that I should raise it here I have raised a ticket here.

Environment: JDK 1.6. Windows, Oracle 11g (11.2 version jar), H2 (1.2 version jar) , Postgre 9.1 (8.3 version jar), both Hibernate 3.x/4.0, we used hibernate3-maven-plugin/ SchemaExport class too.
Project: Hibernate ORM
Labels: hibernate-core Sequence_Generator DDL
Priority: Major Major
Reporter: Chetan
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira