[jboss-user] [EJB 3.0] - @EJB annotation for injection and lazy relations

Nicolas Tanghe do-not-reply at jboss.com
Wed Sep 15 06:02:22 EDT 2010


Nicolas Tanghe [http://community.jboss.org/people/ntanghe] created the discussion

"@EJB annotation for injection and lazy relations"

To view the discussion, visit: http://community.jboss.org/message/561743#561743

--------------------------------------------------------------
Hi,
 
 I develop a ejb3/jsf application.
 I have lazy relations in my entity beans.
 
 I remark that in my managed bean of my JSF, if I use @EJB annotation to  inject session bean, I have no problem on lazy on entity beans returned  by this session bean. 
 
 Example
 
 JsfManageBean{
 
 @EJB
 Bean sessionBean ...
public void doSomething(){
 
 Department d = sessionBean.findDepartmentBy...
 // relation lazy
 d.getEmployees()
 -> Load of employees -> NO LAZY PROBLEM !
 }
 
 }
 
 Someone can explain me why it works ?
 For me, after the find method, my session is closed !
If I do a lookup to find my session bean (and so no injection @EJB here) -> I HAVE THE LAZY PROBLEM !
public void doSomething(){
 
 SessionBean = ... context.lookup("blablabla")
 Department d = sessionBean.findDepartmentBy...
 // relation lazy
 d.getEmployee()
 -> LAZY EXCEPTION
thanks for help !
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/561743#561743]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100915/8400bb2a/attachment.html 


More information about the jboss-user mailing list