-->
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: FOREIGN KEY + KEY + PRIMARY KEY
PostPosted: Tue May 29, 2007 6:33 am 
Newbie

Joined: Tue May 29, 2007 6:20 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2 sp1

Mapping documents:
Test1.hbm.xml :
Code:
   
<class name="Test1" table="test1">
        <comment></comment>
        <id name="a" type="int">
            <column name="a" />
            <generator class="assigned" />
        </id>
        <property name="b" type="string">
            <column name="b" length="5" not-null="true" />
        </property>
        <set name="test2s" inverse="true">
            <key>
                <column name="a" not-null="true" unique="true" />
            </key>
            <one-to-many class="Test2" />
        </set>
</class>

Test2.hbm.xml :
Code:
<class name="Test2" table="test2">
        <comment></comment>
        <id name="a" type="int">
            <column name="a" />
            <generator class="assigned" />
        </id>
        <many-to-one name="test1" class="Test1" update="false" insert="false" fetch="select">
            <column name="a" not-null="true" unique="true" />
        </many-to-one>
        <property name="c" type="string">
            <column name="c" length="5" not-null="true" />
        </property>
</class>


Name and version of the database you are using:MySQL 5.0.37

Hello,

when I use the schema export with hibernate tools, the test2 tables has 3 keys on the a column : a PRIMARY KEY, a simple KEY, and a FOREIGN KEY.

It is clear that the simple KEY is useless. Is there any way to avoid the creation of this KEY ??

thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 5:25 am 
Newbie

Joined: Tue May 29, 2007 6:20 am
Posts: 2
It seems that the KEY doesn't exist. The SHOW INDEX FROM command just shows the FOREIGN KEY and the PRIMARY KEY.

So i guess it's alright !!


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.