-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SchemaExport, subclass and unique-key
PostPosted: Wed Dec 22, 2004 7:16 am 
Newbie

Joined: Thu Dec 18, 2003 4:13 am
Posts: 19
There appears to be a problem when a unique key is defined on a subclass of a hierarchy.
The SchemaExportTask declares the unique key twice in the output DDL, which is not allowed.

Hibernate version: 3.0b1 (problem also occurs with 2.1.6)

Mapping documents (generated by Xdoclet):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-cascade="none" default-access="property" auto-import="true">
<class name="myproject.bean.AOwner" table="TB_OWNER_HRY" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version" mutable="true" batch-size="1">

<id name="oid" column="OID" type="java.lang.Integer" unsaved-value="null">
<generator class="identity"/>
</id>

<discriminator column="DISCRIMINATOR" type="string" length="1" not-null="true" force="false" insert="true"/>
...
<subclass name="myproject.bean.SimpleOwner" dynamic-update="false" dynamic-insert="false" discriminator-value="S">
<property name="userId" type="java.lang.String" update="true" insert="true" access="property" not-null="false" unique="false">
<column name="USER_ID" unique-key="UK_OWNER_ID" not-null="true" unique="true" sql-type="CHAR(10)"/>
</property>

</subclass>

<subclass name="myproject.bean.OwnersGroup" dynamic-update="false" dynamic-insert="false" discriminator-value="G">
...
</subclass>
</class>
</hibernate-mapping>


Ant target:
<target name="prepare">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="class.path"/>
<schemaexport
properties="${toolz.home}/schemaexport.properties"
config="${config.home}/hibernate.cfg.xml"
quiet="no"
text="yes"
drop="no"
delimiter=";"
output="${toolz.home}/creates.sql">
</schemaexport>
</target>

Name and version of the database I am using: HSQLDB 1.7.3

The generated SQL (show_sql=true):
create table TB_OWNER_HRY (
OID integer generated by default as identity (start with 1),
DISCRIMINATOR varchar(1) not null,
NAME varchar(25) not null,
USER_ID CHAR(10) not null,
REF_GROUP integer,
primary key (OID),
unique (USER_ID),
unique (USER_ID)

);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2004 9:55 am 
Newbie

Joined: Thu Dec 18, 2003 4:13 am
Posts: 19
I posted my problems too fast and i forgot to ask the question : has anyone experience such problem ? Is there anything wrong in the mapping file or my ant task ?

Thanx in advance.
Xavier.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.