-->
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 and unique-key
PostPosted: Wed Sep 17, 2003 8:41 pm 
Newbie

Joined: Wed Aug 27, 2003 9:08 pm
Posts: 5
I use SchemaExport to generate a mysql table called userandrole. The table has an internalId, which is the PK. It also has a unique key (index) comprising roleName and userName. The interesting thing is that this unique key generated for the table ignores the specified key name (key1). It uses the first column name of the composite key, ie, roleName. I am not sure if this is intentional or just a small bug in SchemaExport.

Below is the Hibernate descriptor file.

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>
    <class
        name="com.abcd.persist.UserAndRole"
        table="userandrole"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="internalId"
            column="internalId"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="roleName"
            type="java.lang.String"
            update="true"
            insert="true">
            <column name="roleName"
                    unique-key="key1"
                    length="200"
                    not-null="true"/>

        </property>

        <property
            name="userName"
            type="java.lang.String"
            update="true"
            insert="true">
            <column name="userName"
                    unique-key="key1"
                    length="200"
                    not-null="true"/>
        </property>

        <property
            name="creationDate"
            type="java.util.Calendar"
            update="true"
            insert="true"
            column="creationDate"
        />

    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2003 4:43 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The unique constraint name should be "key1". Please open a new JIRA issue.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.