-->
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.  [ 4 posts ] 
Author Message
 Post subject: JPA @JoinTable creating rouge constraint
PostPosted: Wed Apr 23, 2008 3:02 pm 
Newbie

Joined: Tue Aug 03, 2004 2:54 pm
Posts: 9
Can anyone tell me why the SchemaUpdate is adding that unique constraint below (see debug output)? I don't want the unique constraint. What I really want is one constraint, and that is for both columns to be the "primary key" because all this is is a join table for a uni-directional one-to-one mapping. It can not be a bi-directional mapping for this application. Is there any way to do this via JPA annotations and schema update (export). If I drop the constraint, all is well. Even if there was a way to say "don't generate constraints for this object" I'd be happy :)

Here is my annotated List:
Code:
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="TRAV_DOC_2_ACCOUNTS",
        joinColumns={@JoinColumn(name="fdoc_nbr", referencedColumnName="fdoc_nbr", unique=false)},
        inverseJoinColumns={@JoinColumn(name="acct_num", referencedColumnName="acct_num", unique=false)})
private List<TravelAccount> travelAccounts = new ArrayList<TravelAccount>();


Here is the debugging output:
Code:
2008-04-23 14:53:43,197 [main] D: U: DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate :: create table RICE093DEV.TRAV_DOC_2_ACCOUNTS (fdoc_nbr varchar(255) not null, acct_num varchar(255) not null, unique (acct_num))


BTW: Using Hibernate 3.2.6, EM 3.3.0, and mysql 5.x

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 3:43 pm 
Newbie

Joined: Tue Aug 03, 2004 2:54 pm
Posts: 9
Fixed my issue by using a ManyToMany annotation instead of the OneToMany. I still think this is a bug in OneToMany though -- don't know why it is generating a unique constraint. Thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 28, 2008 5:13 pm 
Newbie

Joined: Thu Mar 27, 2008 10:50 am
Posts: 13
I too am interested in knowing the reason the rogue unique constraint is generated.


Top
 Profile  
 
 Post subject: Bump
PostPosted: Mon Sep 15, 2008 12:10 pm 
Newbie

Joined: Thu Mar 27, 2008 10:50 am
Posts: 13
Could some expert please respond/shed some light? It will be a great help. This unique constraint on second (many-side) column is very disturbing for us.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.