-->
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.  [ 1 post ] 
Author Message
 Post subject: @oneToMany weird DDL generation
PostPosted: Sun Dec 05, 2010 2:09 pm 
Newbie

Joined: Sat Sep 26, 2009 2:13 pm
Posts: 6
Hi,

I have the following annotation:

Code:
class Event....
@OneToMany(cascade = CascadeType.ALL)
@OrderColumn(name = "idx")
@CollectionTable(name = "event_owners")
private List<User> eventOwners = new ArrayList<User>();


Unless I am really tired, the above should generate (I use hibernate to create tables) a table 'event_owners' with a index column 'idx', 'Event_id' and 'User_id'.
The constraints should be unique on (event_id,user_id) and (event_id,user_id,idx) with user_id also being a primary key.
What I get is the following:
Code:
| event_owners | CREATE TABLE `event_owners` (
  `Event_id` bigint(20) NOT NULL,
  `eventOwners_id` bigint(20) NOT NULL,
  UNIQUE KEY `eventOwners_id` (`eventOwners_id`),
  KEY `FK3884AD65FF21B5B8` (`Event_id`),
  KEY `FK3884AD65C21A1E0D` (`eventOwners_id`),
  CONSTRAINT `FK3884AD65C21A1E0D` FOREIGN KEY (`eventOwners_id`) REFERENCES `use
r` (`id`),
  CONSTRAINT `FK3884AD65FF21B5B8` FOREIGN KEY (`Event_id`) REFERENCES `event` (`
id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |


As you can see it generates - UNIQUE KEY `eventOwners_id` (`eventOwners_id`), - which makes this effectively a onetoone mapping.
Do you see anything wrong or is it a bug?
Thanks.
-----
I am using 3.6.0.Final and MySQL 5.1.6.
Note this is a Unidirectional mapping


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

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.