-->
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.  [ 2 posts ] 
Author Message
 Post subject: Selectively avoiding FK constraints generation
PostPosted: Thu May 10, 2007 9:21 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
Hi folks,

is it possible to avoid the creation of an FK constraint for an one-to-many association?

I have the following:

@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="targetId")
@Where(clause="targetKind='P'")
private List<Review> reviews = new ArrayList<Review>();


The 'P' is acting as a discriminator here, between different review targets. The target of the review is in fact determined from a pair <discriminator,id>. So I really don't want that the id was constrained by a FK constraint (that id should for all purposes be a simple integer except for its use as a join field coupled with the discriminator).

But then I don't know how to tell hibernate that the FK is not meant to be generated, if this is possible at all. For the schema auto-generation I use:

<property name="hibernate.hbm2ddl.auto">update</property>

Any hints will be appreciated.
TIA.
Cheers,
Carlos


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
there is not generated way to do that, you can generate the DDL file and adjust it.

Note that an updateable DB view elegantly solves your mapping problem

_________________
Emmanuel


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