-->
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: @ManyToOne with invalid foreign key
PostPosted: Thu Sep 28, 2006 12:59 am 
Newbie

Joined: Tue Mar 22, 2005 6:01 pm
Posts: 13
Location: Sydney, Australia
Hi Guys,

I have a case where i have a ManyToOne as in:

Code:
@ManyToOne   @JoinColumns({@JoinColumn(name="ITEM_NR"),@JoinColumn(name="PSI")})
   private Item item;


but the actual value in the foreign key columns do not match any instances of the primary key columns in the target table.

I would like this to just be ignored by hibernate and the ManyToOne property to just be set to null. But hibernate throws an exception instead.

Is there anyway of getting hibernate to ignore this mismatch and just return an object with the relavent ManyToOne property set to null?

Thanks in advance.
J


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 1:15 am 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
Yep, just add the below annotation in addition to the @ManyToOne

Code:
@NotFound(action=NotFoundAction.IGNORE)



See the documentation here:
http://www.hibernate.org/hib_docs/annot ... ingleassoc


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.