Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Safe to story entity in a web session obtained from @PersistenceContext ?

I've actually figured out my behavior here, the only time lazy
fetching works inside a jsp for me was actually inside a JSP like I
said, it actually worked inside a taglib I was using which held it's
own DAO, so that makes sense :)

./tch



On Wed, Jul 14, 2010 at 10:51 PM, Shashikant Kale
<Shashikant.Kale@xxxxxxxxxxxxxxxx> wrote:
> Are you using spring transactions? If yes, may be it would be a good idea to enable spring logs (log4j) which could give a hint about the transaction boundary. JSP lazy init should not be any different from any web layer component calling a spring dao bean (transactional and em injected using PersistenceContext) for an entity. The entity obtained once crosses spring dao bean method becomes detached. If I call methods like remove on this entity should give an exception saying entity is in unmanaged state.
>
> --Shashi
>
> -----Original Message-----
> From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Tim Hollosy
> Sent: Wednesday, July 14, 2010 11:46 PM
> To: EclipseLink User Discussions
> Subject: Re: [eclipselink-users] Safe to story entity in a web session obtained from @PersistenceContext ?
>
> I've noticed that too, but I've also noticed that lazy init via JSP
> seems to work, wouldn't the transaction boundary be over and the
> entity be detached by then?
>
> ./tch
>
>
>
> On Wed, Jul 14, 2010 at 1:28 PM, Shashikant Kale
> <Shashikant.Kale@xxxxxxxxxxxxxxxx> wrote:
>> We have been using spring managed em (eclipselink as provider) alongwith spring transactions. AFAIK an em is created with a spring transaction and is closed when transaction is committed/rolled back. Thus the entity 'managed to unmanaged' lifecycle is bound to the transaction boundary.
>>
>> HTH,
>> Shashi
>>
>> -----Original Message-----
>> From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Tim Hollosy
>> Sent: Wednesday, July 14, 2010 10:47 PM
>> To: EclipseLink User Discussions
>> Subject: [eclipselink-users] Safe to story entity in a web session obtained from @PersistenceContext ?
>>
>> This is more of a spring question, but I'm curious. We inject our
>> EntityManager to our DAO using the @PersistenceContext annotation.
>> Would it be safe to throw an entity in the session without explicit
>> cleanup of the entity or would that entity stay managed? I'm concerned
>> that over time I'd run into memory issues. I can't find a programmatic
>> way to detach an entity short of calling close on the EntityManager
>> but I don't want to do that, since in spring it's shared.
>>
>> I plan on running some experiments to see how long that entity stays
>> managed, but I thought I'd ask here to see if anyone's dealt with this
>> in the past.
>>
>> ./tch
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top