struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caine Lai" <caine...@gmail.com>
Subject Re: How does one use lazy loading in Struts 2 with container managed persistence?
Date Sun, 03 Jun 2007 05:23:15 GMT
Hi Jeromy,

Thanks for your response.  It sounds like your solution works, but it
doesn't seem like this would integrate with container managed persistence
very well.

It's strange this is so difficult to achieve in the "next generation"
struts.  I don't know why JPA/EJB3 is an afterthought.  I really don't want
to abandon Struts 2 at this point since it was exactly what I was looking
for except for this one very large issue.

I'd still be very interested in hearing from anyone that has thought about
or solved this problem of using Struts 2 in a managed environment.

Thanks,
Caine

On 6/2/07, Jeromy Evans <jeromy.evans@blueskyminds.com.au> wrote:
>
> Hi Caine,
>
> I use JPA. I place the EntityManagerFactory into the application context
> so it can be accessed by an S2 interceptor.
> The S2 interceptor creates an EntityManager for each request as per the
> open session in view pattern and so lazy loading can be used where
> appropriate.
> This doesn't qualify as CPM though which is what you asked for. I
> haven't tried using S2 with an EJB container yet.
>
> There's no need to use spring.
>
> cheers,
> Jeromy Evans
>
> Caine Lai wrote:
> > No one?  This seems like a major design flaw in Struts 2, if there is
> > no way
> > to use lazy loading in Struts 2 using JPA.
> >
> > I've read something online that describes it may be possible to write a
> > custom interceptor that can scan for annotations and inject the
> > persistence
> > context into a struts action.  But without framework support for JPA
> > (built
> > in), how can Struts 2 ever be taken seriously?  Isn't EJB3 and JPA the
> > current standard spec?
> >
> > I'm not at all interested in using Spring either.  And quite fankly I
> > shouldn't be forced to use Spring purely for the Open Session in View
> > pattern.
> >
> > Thoughts?
> >
> > On 6/1/07, Caine Lai <cainelai@gmail.com> wrote:
> >>
> >> I'm using EJB3 stateless session beans/JPA/JTA to manage my data
> access.
> >> But I can't figure out how one would use lazy loading in this
> >> scenario since
> >> any transaction opened in the EJB layer will already be committed
> >> prior to
> >> rendering the view.
> >>
> >> Any tips?
> >>
> >> I'm familiar with "Open Session in View" when using hibernate, but it's
> >> not quite the same when I'm using container managed transactions and
> >> dependency injection in EJB3.  Or is it?  Would I still open a
> hibernate
> >> session within the view and close it after the view is rendered in this
> >> scenario?
> >>
> >> Thanks for any pointers.
> >>
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.472 / Virus Database: 269.8.7 - Release Date: 2/06/2007
> 12:00 AM
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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