Here's the scenario: I have a Servlet which uses JNDI to get a stateless 
session bean.  That stateless session bean has a method like "load" which loads 
up one of my entities.

So now my Servlet has gotten a hold of its entity bean.  Let's say this entity 
is an Invoice which contains a List of Items.

Then the Servlet puts that Invoice object into the request as an attribute, and 
uses JSP to do the display.  The JSP now iterates through the List of Items.

Here's the problem: What if that List of Items hasn't been initialized?  That 
List might be just a stub.  It needs to get all its Items, and then it needs to 
get values out of the Items (like price, description, etc).  But by now, there 
is no more entity manager.

How can these proxies be resolved in a situation like this?  What is the way to 
handle this?

It seems like a common problem.  I know that back when I was using Hibernate 
and plain old Tomcat (not within JBoss), I set up a Filter for everything.  The 
Filter would create a Hibernate Session, load the objects it needed, call 
doFilter() to actually display everything, and then call session.close() so the 
session wouldn't be left dangling.

What's the right way to do this within JBoss?  I have a feeling that the answer 
might be "use Seam", but I don't want to do that at this stage, because a) I 
have a lot of existing JSPs that I can't rewrite and b) I'm still getting 
myself comfortable with JBoss / EJB and I don't want to add in yet another 
technology I need to learn before I can demo this project to customers.

Any thoughts on this?

By the way, using EJBs within JBoss is quite amazing.  I set up my classes, I 
deploy them, all the tables magically appear, and it is just cool.  So this 
question is the last barrier I have to being able to use EJBs + JBoss as an 
effective tool.

Thanks


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964559#3964559

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964559
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to