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
|