-->
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: Passing a graph of detached objects back
PostPosted: Thu Jul 22, 2004 8:31 pm 
Beginner
Beginner

Joined: Thu Jul 01, 2004 1:30 pm
Posts: 20
Location: Tucson, AZ
In an environment where Hiberante is integrated with J2EE AS. Session beans SA and SB. Client calls SA, which then calls SB several times to do a complex business logic. SB will retrieve a relatively large graph of objects and return it to SA, which makes changes to that graph of objects. Then SA passes the modified object graph to SB to be persistent. After reading hiberante manual and "in action" book, I decided to use session-per-request and detached objects pattern. I also use CMT, in which SB joins a flat JTA transaction initiated by SA, so if any one of the calls from SA to SB fails, the whole transaction aborts.

My question is how to efficiently return a graph of objects (around 10 or more, which references each other) from session bean SB back to SA? And also how to pass the modified object graph from SA to SB? Using DTO? Or just pass the root node of the graph and the serialize() will recursively serialize the whole graph of objects?

Thanks,
Stan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 9:03 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
How are you referencing SB from SA? Are you creating an instance through SB's Home Interface? If so, just pass the graph's root object and let serialization handle everything for you, unless there is a reason why this would not be acceptable. Make sure you handle any Singletons and Enumerated Types properly during the deserialization process. Check out Joshua Bloch's book 'Effective Java' for pointers on how to do this.
If you are not looking up an instance of SB (e.g. using a constructor or factory method to obtain the instance), you are simply referencing it directly inside the JVM, and there is no need to worry about serialization. Normal Java rules apply and you will pass the graph's root object via a reference by calling any method on SB.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 23, 2004 7:07 pm 
Beginner
Beginner

Joined: Thu Jul 01, 2004 1:30 pm
Posts: 20
Location: Tucson, AZ
Yes, SA calls SB by its HomeObject and EJBObject.

Thank you for your answer and refering me to the book "Effective Java". This is very helpful!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 23, 2004 9:22 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
Glad I could help. One other thing to keep in mind is that even if you are creating your instances through the Home interface, if your EJB JAR and web applications are running in the same container, your container may offer a feature to allow passing arguments by reference between applications (I know at least WebLogic 8.1 has this). You will want to check whether or not this is enabled.
Or of course if you are using Local EJBs this is effectively the same thing.


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.