-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate in event driven environment
PostPosted: Wed Jun 28, 2006 5:09 am 
Newbie

Joined: Mon Jul 25, 2005 2:49 pm
Posts: 3
Hi,

Currently I'm investigating wether Hibernate would fit in our architecture, which is event driven.
One of the requirements is that we want to be able to use lazy loading.

Let's say one process fetches object Parent which has a (lazy-loaded) relationship with Child. The process publishes an event with the Parent object on the event router and by doing so the Parent object gets serialized.

Now first of all we don't want that the serialization will initialise the Child collection.

Secondly another process which is "listening" to Parent objects gets the object from the event-router. This process wants to assess the Child collection so this other process which has a connection to the same database as well, wants to be able to initialise the collection.

Does Hibernate fit in this kind of architecture?

Cheers,

Jan-Erik


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 7:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You'd have to be very clever about it, as the lazy loading requires that the session that loaded parent must still be available when child is referenced. That, of course, means that the parent object can only be referenced on a single machine, and your mention of an "event router" suggests that there's more than one machine involved.

The serialization thing isn't a problem, so long as proxied associations are referenced only where the session is available. You can declare the fields as transient (to prevent serialization) and hibernate will cope fine.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 3:37 am 
Newbie

Joined: Mon Jul 25, 2005 2:49 pm
Posts: 3
Well that's the thing. The other process which will try to navigate from Parent to Child is on another machine most of the times, so the session which is associated with Parent is not availlable there.
Isn't it possible to tell Hibernate to just use a new session?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 5:46 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Pure lazy loading requires use of the same session. You can work around it in your code though, by detaching the object as it leaves one session (session.evict) and reattaching it when it arrives at the new session (session.lock then session.refresh). It won't be able to take advantage of the original session's cache, but in all other ways, it's the same.

_________________
Code tags are your friend. Know them and use them.


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