Hello,
I am trying to get SchemaExport to dump a schema into HSQLDB when I start an in memory database. However, the sql SchemaExport is sending has duplicate columns (see the sql snippit below). In this case, the roleid column is being declared twice, which hsqldb doesn't like. I doublechecked my mapping document, and I seems to be correct. Any suggestions?
Thanks,
Matt
Hibernate version:
2.1.8
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.dbsnow.domain.Workorderauthorization"
table="WORKORDERAUTHORIZATION"
schema="OPTOOLS"
mutable="false"
>
<cache usage="read-only" />
<id name="userid" column="userid" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="roleid" column="roleid" type="java.lang.Integer" not-null="true"/>
<set name="users" lazy="true">
<cache usage="read-only" />
<key column="USERID"/>
<one-to-many class="com.dbsnow.domain.Systemuser"/>
</set>
</class>
</hibernate-mapping>
Code for persistant class:Code:
package com.dbsnow.domain;
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class Workorderauthorization implements Serializable {
/** identifier field */
private Integer userid;
/** persistent field */
private Integer roleid;
/** persistent field */
private Set users;
/** full constructor */
public Workorderauthorization(Integer roleid, Set users) {
this.roleid = roleid;
this.users = users;
}
/** default constructor */
public Workorderauthorization() {
}
public Integer getUserid() {
return this.userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public Integer getRoleid() {
return this.roleid;
}
public void setRoleid(Integer roleid) {
this.roleid = roleid;
}
public Set getUsers() {
return this.users;
}
public void setUsers(Set users) {
this.users = users;
}
public String toString() {
return new ToStringBuilder(this)
.append("userid", getUserid())
.toString();
}
}
Name and version of the database you are using:HSQLDB 1.8.0 RC12
The generated SQL (show_sql=true):Code:
create table OPTOOLS.WORKORDERAUTHORIZATION (
userid integer not null,
roleid integer not null,
ROLEID integer,
primary key (userid)
)
Debug level Hibernate log excerpt:17:20:32,817 DEBUG SchemaExport:149 - create table OPTOOLS.WORKORDERAUTHORIZATION (
userid integer not null,
roleid integer not null,
ROLEID integer,
primary key (userid)
)
17:20:32,817 ERROR SchemaExport:154 - Unsuccessful: create table OPTOOLS.WORKORDERAUTHORIZATION (userid integer not null, roleid integer not null, ROLEID integer, primary key (userid))
17:20:32,817 ERROR SchemaExport:155 - Column already exists in statement [create table OPTOOLS.WORKORDERAUTHORIZATION (userid integer not null, roleid integer not null, ROLEID integer]
[/code]