Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Accessing a lazy-field of a managed entity in another thread

That's correct - instantiating a lazy collection on a managed entity should not be done in another thread.
However I believe that in Eclipselink that could be done on a detached entity (though the spec doesn't require support for lazy attributes instantiation on detached entity)
On 2/26/2015 9:06 AM, Rick Curtis wrote:
When speaking in general JPA, you should avoid sharing managed Entities / EntityManagers across threads. Unfortunately I don't have first hand experience in this area with EclipseLink, but some of my previous experiences with other providers tells me this is a bad idea. 

Hopefully someone else on the list has some more concrete information for you.

Thanks,
Rick

On Wed, Feb 25, 2015 at 1:58 PM, Andreas Joseph Krogh <andreas@xxxxxxxxxx> wrote:
Hi all.
 
Say I have this code:
 
Person person = em.find(...)
asyncDispatcher.process(person) // hands managed entity to another thread
 
Then some other thread calls person.getLazyMappedCollection.foreach(...)
 
Is this safe or may it result in all sorts of exceptions and/or resource-leaks (sql.Connection/ResultSet leak etc.)?
 
Thanks.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



--
Rick Curtis


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top