-->
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: @ManyToMany association's schema breaks ManyToMany
PostPosted: Wed Apr 09, 2008 3:59 pm 
Newbie

Joined: Mon Mar 05, 2007 5:21 am
Posts: 4
Hi everyone. This one's been a thorn in the side for quite some time, so any help (or pointers to a good book! JP with Hibernate isn't doing it for me) would be really appreciated.

Hibernate v.3.2.1 GA.

Code:
@ManyToMany
@org.hibernate.annotations.CollectionOfElements
@JoinTable(
   name="QuestionGroup_Question",
   joinColumns={@JoinColumn(name="QGROUPNAME_ID", referencedColumnName="id", unique=false)},
   inverseJoinColumns={@JoinColumn(name="Q_ID", referencedColumnName="id", unique=false)}
   )
@IndexColumn(name="ORDER_IDX", base=1)
List<Question> questions = new ArrayList<Question>();


The problem is, this is the generated MySQL schema:
Code:
mysql> describe QuestionGroup_Question ;
+---------------+------------+------+-----+---------+-------+
| Field         | Type       | Null | Key | Default | Extra |
+---------------+------------+------+-----+---------+-------+
| QGROUPNAME_ID | bigint(20) | NO   | PRI |         |       |
| Q_ID          | bigint(20) | NO   | UNI |         |       |
| ORDER_IDX     | int(11)    | NO   | PRI |         |       |
+---------------+------------+------+-----+---------+-------+
3 rows in set (0.03 sec)


Specifically, Q_ID has to be unique!! It's essentially a many-to-one, and I don't know what's causing it.

Does anyone see anything wrong with my annotations? Or is there something else I should add? Is there another way to specified an ordered many-to-many that's worked for anyone?

Any help would be really appreciated. Thanks in advance!

_________________
Ph.D. Candidate, Computer Science
Virginia Tech


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.