Hi,
I am trying to generate the DDL scripts with hibernatetool/hbm2ddl for Oracle and MS SQLServer. I use Hibernate Entity Manager as JPA provider and my classes are annotated using JPA (no hibernate-specific stuff, just plain JPA).
Generation of mssql passes without any problems, but when it comes to oracle, the following error is issued:Code:
[hibernatetool] Nov 4, 2009 1:42:22 PM org.hibernate.dialect.Dialect <init>
[hibernatetool] INFO: Using dialect: org.hibernate.dialect.Oracle10gDialect
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: Dialect does not support identity key generation
Any suggestions how to make Oracle DDL export work with @GeneratedValue(strategy = GenerationType.AUTO)?Below you can find more details.
I have the basic entity as:
Code:
@MappedSuperclass
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "name", length = 100, nullable = false, unique = true)
private String name;
...
// here I have some entities like that:
@Entity
@Table(name = "clm_group")
@Inheritance (strategy = InheritanceType.TABLE_PER_CLASS)
@AttributeOverrides(
value = {@AttributeOverride(
name = "id", column = @Column(name = "group_id")
)}
)
public class Group extends BaseEntity implements Serializable {
...
}
Ant task is defined as follows:
Code:
...
<macrodef name="ddl">
<attribute name="db"/>
<sequential>
<hibernatetool destdir="scripts">
<jpaconfiguration
propertyfile="config/@{db}-hibernate.properties"
persistenceunit="clm"/>
<classpath>
<fileset dir="${dist}"/>
<path refid="tools.classpath"/>
</classpath>
<hbm2ddl
export="false"
outputfilename="@{db}.sql"
format="true"
haltonerror="true"/>
</hibernatetool>
</sequential>
</macrodef>
<target name="generate-ddl" depends="jar">
<ddl db="mssql"/>
<ddl db="oracle"/>
</target>
...
The property files named as mssql-hibernate.properties and oracle-hibernate.properties, and just set the hibernate.dialect=org.hibernate.dialect.SQLServerDialect and hibernate.dialect=org.hibernate.dialect.Oracle10gDialect respectively.
I supposed, that Hibernate and hbm2ddl MUST select appropriate ID generation strategy, but as I see this doesn't happen...