I am using hibernate3-maven-plugin version 2.0 hbm2ddl to generate SQL scripts from code. I am using process-classes. I my Entity class I am using a sequence. @SequenceGenerator(name="sessionSeq", sequenceName="SESSION_SEQ", allocationSize=50, initialValue=1) When I run the Maven script, this generates create sequence hibernate_sequence; I wanted it to generate something like create sequence hibernate_sequence increment by 50;

Can someone help me?

I am using the following jars : hibernate-tools - 3.2.4.GA, hibernate-core - 3.6.1.Final, hibernate-entitymanager - 3.6.1.Final, hibernate-validator - 4.1.0.Final, hibernate-validator-legacy - 4.0.2.GA and DB related jars.

The hbm2ddl is not picking up the allocationSize=50 property of the @SequenceGenerator when I am trying to generate the .SQL file.

This is an extract of the code:

@Entity @SequenceGenerator(name="sessionInfoIdSeq", sequenceName="SESSIONINFO_ID_SEQ", allocationSize=50)

public class SessionInfo {

@Id  @GeneratedValue(strategy = GenerationType.AUTO, generator="sessionInfoIdSeq")
private Integer          id;
  • I tried using the SchemaExport class as defined in the blog java-tutorial.ch/hibernate/generate-ddl-with-hibernate. – Test Feb 5 '13 at 3:24
  • The output generated was drop table UserEntity cascade constraints; drop sequence main.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 main.attachment_id_seq; This was not what I expected. I wanted the allocationSize to be reflected in the Sequence definition. – Test Feb 5 '13 at 3:31
  • Checked the API for hibernate-core-3.6.1 Final which is being used by the SchemaExport API. The SequenceGenerator.java class that was getting called from this jar was using a deprecated method from the Dialect class which was generating the Sequence Definition. The method was public String[] getCreateSequenceStrings(String sequenceName), instead if it would use the String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) from the Dialect class, it would have solved my problem. – Test Feb 5 '13 at 17:46
up vote 0 down vote accepted

Checked the API for hibernate-core-3.6.1 Final which is being used by the SchemaExport API. The SequenceGenerator.java class that was getting called from this jar was using a deprecated method from the Dialect class which was generating the Sequence Definition. The method was public String[] getCreateSequenceStrings(String sequenceName), instead if it would use the String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) from the Dialect class, it would have solved my problem.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.