I have the following annotation:
@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:
| 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
CONSTRAINT `FK3884AD65FF21B5B8` FOREIGN KEY (`Event_id`) REFERENCES `event` (`
) 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?
I am using 3.6.0.Final and MySQL 5.1.6.
Note this is a Unidirectional mapping