-->
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.  [ 3 posts ] 
Author Message
 Post subject: OneToMany - parent column not PK
PostPosted: Wed Nov 14, 2007 7:27 am 
Newbie

Joined: Wed Jan 11, 2006 9:57 pm
Posts: 2
Hi, I have a one-to-many relationship based on a join table defined this way:


Code:

@OneToMany(targetEntity = SoftGenre.class, fetch=FetchType.LAZY)
   @LazyCollection(LazyCollectionOption.EXTRA)
   @JoinTable(name = "PROGRAMME_FEATURE",
         joinColumns = { @JoinColumn(name = "PROGRAMMEID", referencedColumnName="PROGRAMME_ID", unique=false, nullable=false, insertable=false,updatable=false ) },
         inverseJoinColumns = { @JoinColumn(name = "WORD", referencedColumnName="SOFTGENREID", unique=false, nullable=false, insertable=false,updatable=false) })


The column PROGRAMME_ID of the source entity is not a PK (and is not UNIQUE).
When running hbm2ddl to create/update my schema, a UNIQUE constraint is created for this column, even when it's annotated as unique=false.

How can I solve this?

Thanks,
Juan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 7:49 am 
Regular
Regular

Joined: Thu Nov 13, 2003 2:55 am
Posts: 71
Location: Sweden
With only a vague picture of what you are doing, I'm guessing here:
If PROGRAMME_ID is not unique, isn't this a many-to-many rather than a one-to-many?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 7:59 am 
Newbie

Joined: Wed Jan 11, 2006 9:57 pm
Posts: 2
it is, but I'm only interested in one side of the relationship and it's about read only tables.

Thanks,
Juan


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