0

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;
3
  • I tried using the SchemaExport class as defined in the blog java-tutorial.ch/hibernate/generate-ddl-with-hibernate. Commented Feb 5, 2013 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. Commented Feb 5, 2013 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. Commented Feb 5, 2013 at 17:46

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.