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