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;
4

1 回答 1

0

检查了 SchemaExport API 正在使用的 hibernate-core-3.6.1 Final 的 API。从此 jar 中调用的 SequenceGenerator.java 类使用了 Dialect 类中已弃用的方法,该方法正在生成序列定义。该方法是 public String[] getCreateSequenceStrings(String sequenceName),而不是如果它使用来自 Dialect 类的 String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize),它会解决我的问题。

于 2013-02-05T17:49:31.083 回答