question about synchronization in 1:n relationships

Abid Hussain <[email protected]> Wed, 22 Oct 2008 10:00:12 +0200
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hello everybody,

I except not to be the first one to ask this question, but haven't found 
anything in the archives.

My question is about synchronization resp. caching of 1:n relations. Let's say, 
we have two entities:
class Event {
	int id;
	int eventTypeId;
	EventType eventType;
	// ... other fields
}
class EventType {
	int id;
	Collection<Event> events;
	// ... other fields
}
So, there is a 1:n relationship between EventType and Event - EventType is on 
the 1-side and Event is on the n-side.

Let's look at the following:
(1) We fetch an EventType (called evType) from DB incl. all the associated Events.
(2) Another user deletes an Event from the DB which was associated with the 
previously fetched EventType.
(3) At this point, an Event is included in the evType's events-collection which 
doesn't exist any more cause it was deleted in (2).

Is there any caching or synchronization mechanism to avoid the problem in (3)?

Regards,

Abid


-- 

Abid Hussain
Mail: [email protected]
Web: http://www.abid76.de