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.  [ 3 posts ] 
Author Message
 Post subject: create UNIQUE index using xml mapping
PostPosted: Fri Jun 24, 2005 1:20 pm 
Newbie

Joined: Fri Jun 24, 2005 9:29 am
Posts: 2
Hi,

I am trying to create unique index out of two columns, as show in the mapping xml file. the unique = "true" does not make the index unique, instead, it makes each column a unique key.

My question is:
How can I make unique index, using SchemaExport, in Hibernate .hbm.xml mapping file?

Thank you!

Fan

Hibernate version:
3.0
Mapping documents:
<hibernate-mapping>
<class entity-name="EQ_REFERENCE">
...
...
...
<property name="EXTERNALIDENTIFIER" type="string" length="25">
<column name="EXTERNALIDENTIFIER" not-null="true" unique="true" index="INDEX_EXTERNALIDENTIFIERDELET"/>
</property>
<property name="DeletedStamp" type="timestamp">
<column name="DeletedStamp" unique="true" index="INDEX_EXTERNALIDENTIFIERDELET"/>
</property>
...
...
...
</class>
Name and version of the database you are using:
MySql 4.1, mysql-connector-java-3.1.8-bin.jar
The generated SQL (show_sql=true):
...
...
...
UNIQUE KEY `EXTERNALIDENTIFIER` (`EXTERNALIDENTIFIER`),
UNIQUE KEY `DeletedStamp` (`DeletedStamp`),
KEY `INDEX_EXTERNALIDENTIFIERDELETEDSTAMP` (`EXTERNALIDENTIFIER`,`DeletedStamp`)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 2:58 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
check out the <properties> tag in the docs.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 26, 2005 2:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes, or:

unique-key="name"

or, perhaps the best way in very recent versions of HB3 is

<natural-id>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.