-->
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: mapping command "unique-key"
PostPosted: Thu Jul 28, 2005 8:12 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 8:51 pm
Posts: 20
Location: Bergamo, Italy
Can you give me more info on mapping command "unique-key" for autogenerate database?
In books about hibernate i found not material about it..

My problem follows:

this are to table i have to map, but i prefer use hibernate autogenerate table.

CREATE TABLE `attributes` (
`Name` varchar(50) NOT NULL default '',
`Type` smallint(6) NOT NULL default '1',
`Column_` varchar(50) NOT NULL default '',
`Object` varchar(50) NOT NULL default '',
PRIMARY KEY (`Object`,`Name`),
CONSTRAINT `attributes_ibfk_1` FOREIGN KEY (`Object`) REFERENCES `objects` (`Name`) ON UPDATE CASCADE
) TYPE=InnoDB;

CREATE TABLE `fuzzyattributes` (
`Name` varchar(50) NOT NULL default '',
`Min_` float NOT NULL default '0',
`Max_` float NOT NULL default '0',
`variance` float NOT NULL default '0',
`Object` varchar(50) NOT NULL default '',
PRIMARY KEY (`Object`,`Name`),
CONSTRAINT `fuzzyattributes_ibfk_1` FOREIGN KEY (`Object`, `Name`) REFERENCES `attributes` (`Object`, `Name`) ON UPDATE CASCADE
) TYPE=InnoDB;

I create the mapping file adding an id entry for each table, making them primary key. So as you see the old primary key have to became at least unique each other (object & name). How can i map them?
I thought to use unique, but it realize only a one attribute key.
So i thought to "unique-key" and bind the to parameters.. it is the right path? How to realize?

tnk


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 8:24 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Code:
<property name="Object"...>
   <column name="Object" unique-key="uk_object_name".../>
</property>

<property name="Name"...>
   <column name="Name" unique-key="uk_object_name".../>
</property>


Best regards
Sven


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.