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: How to handle dangling N:1 references?
PostPosted: Wed Jun 16, 2004 1:11 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 6:04 am
Posts: 161
Location: Linz, Austria
Let's assume a persistent class SearchCriteria that can reference a ProductGroup via an N:1 assocation. The ProductGroup does not have a reference back to the SearchCriterias, because it doesn't need to.

Now when a ProductGroup gets deleted, SearchCriteria entries that have referenced it contain an invalid target id. Unfortunately, this will lead to a HibernateException on loading such a SearchCriteria object because the referenced ProductGroup does not exist anymore.

What I'd like to achieve is that those SearchCriteria objects can still be loaded but somehow indicate that the referenced ProductGroup does not exist anymore. Unfortunately, I don't see a straightforward way to achieve this, neither via an Interceptor nor via implementing Lifecycle.

This requirement is by no means far-fetched, so I guess the problem must be quite common. Am I missing something obvious here? How do you approach such a scenario?

Juergen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 5:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You'd have to implement a custom persister to acheive something like that. Or I guess you could utilize a UserType to manage the association, rather than mapping it directly as a <many-to-one/>.


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.