I'm unable to get schema export working with either Hsql 1.7.1 or 1.8.0. The errors differ in either case, but it fails with both. See below for sample mapping file and the exact log output from Hibernate. In summary:
With 1.7.1, I get an error, "Unexpected token: GENERATED"
With 1.8.0, I get an error, "Constraint already exists in statement [create table users (..., unique (login), unique (login))]
What do I need to do to get Hibernate and Hsql to work together using hibernate.hbm2ddl.auto=create?
I also tried with hibernate.hbm2ddl.auto=update, which is what I'd rather use, but that fails even sooner with a failure to read metadata followed by a table not found error...
L.
Hibernate version:
3.1
Mapping documents:
Sample:
<hibernate-mapping package="com.foo" default-access="field">
<class name="UserBO" table="users" lazy="true">
<id name="id"><generator class="native"/></id>
<natural-id mutable=" false">
<property name="loginId" column="login" length="32" not-null="true" unique="true"
access="field"/>
</natural-id>
<property name="password" length="32" not-null="true" access="field"/>
<property name="name" length="32" not-null="true" access="field"/>
<property name="email" length="32" not-null="true" access="field"/>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Hsql 1.7.1 / 1.8.0
The generated SQL (show_sql=true):
With Hsql 1.7.1:
ERROR [main] org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table users (id integer generated by default as identity (start with 1), login varchar(32) not null, password varchar(32) not null, name varchar(32) not null, email varchar(32) not null, primary key (id), unique (login), unique (login))
ERROR [main] org.hibernate.tool.hbm2ddl.SchemaExport - Unexpected token: GENERATED in statement [create table users (id integer generated by default as identity (start with 1), login varchar(32) not null, password varchar(32) not null, name varchar(32) not null, email varchar(32) not null, primary key (id), unique (login), unique (login))]
With Hsql 1.8.0:
ERROR [main] org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table users (id integer generated by default as identity (start with 1), login varchar(32) not null, password varchar(32) not null, name varchar(32) not null, email varchar(32) not null, primary key (id), unique (login), unique (login))
ERROR [main] org.hibernate.tool.hbm2ddl.SchemaExport - Constraint already exists in statement [create table users (id integer generated by default as identity (start with 1), login varchar(32) not null, password varchar(32) not null, name varchar(32) not null, email varchar(32) not null, primary key (id), unique (login), unique (login))]
_________________ Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
|