struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Nenning <Christoph.Nenn...@lex-com.net>
Subject Antwort: Struts2, EJB 3.1, JPA 2 and OpenJPA.
Date Fri, 20 Sep 2013 11:03:38 GMT
> 
> Hello, I have a problem with Struts 2 and OpenJPA.
> I use Websphere 8.5 as Application server. OpenJPA as persistence 
provider.
> I have developed a web application with Struts 2 as main framework.
> In this webapp there is EJB 3.1 and JPA 2 as technologies.
> 
> I call an struts action, the action call the ejb, ejb execute a query 
and
> return an object (entity) to the action.
> The entity has some relationship with other entity mapped as lazy.
> 
> When i have the object back in the action, i have the problem of how
> resolve the lazy loading of the relation.
> 
> One solution is obtain persistencecontext into the action so the object
> isn't detached and i can resolve the lazy loading.
> But how can i obtain persistencecontext into a Struts2 Action?
> 
> 
> Thanks in advance and have a nice day.


A common pattern for this is to create your own TransactionInterceptor. 
That would open the persistencecontext before the action executes and 
close it after the result is finished. If you use Prepareable you must 
place it before PrepareInterceptor in your stack.


Regards,
Christoph

This Email was scanned by Sophos Anti Virus

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message