Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Small clarification needed on server session usage

A single EntityManager should not be used by multiple threads, this is just
logical, as an EntityManager represents a single request or transaction, it
should not be used by multiple users, a new EntityManager should be acquired
per user/thread.  An EntityManagerFactory can be used by multiple
threads/users.

The same goes for EclipseLink's native API, a ServerSession can be used by
multiple users/threads, but each user/thread should acquires its own
ClientSession.  A ClientSession and UnitOfWork should never be used by
multiple users/threads.

The ServerSession also shares the meta-data, you could also share this with
multiple DatabaseSession's but you would need to ensure you cache the
Project.


Rohit Banga-2 wrote:
> 
> One advantage of using serverSession even with a third party data source 
> can be that there will be a shared cache for all client sessions. Other 
> than that anything else?
> 
> On 3/6/2011 6:23 PM, Rohit Banga wrote:
>> Hi All     Based on the wiki we have the following facts: 1. A 
>> database session should typically be used with a two tier application.
>> 2. For three tier applications we should get a server session from 
>> EntityManagerFactory and then for each subsequent request we should 
>> acquire a client session and then if required a unit of work from the 
>> client session; subsequently releasing the client session. This allows 
>> us to reuse connections pooled by the server session. But what happens 
>> when we use a third party datasource. The connection pool is not owned 
>> by the server session. so each acquireClientSession() will request a 
>> connection from the datasource. In this case does it really matter 
>> whether we use a database session or a server session?
>> As a side note, in some of the previous posts I have read that an 
>> EntityManager is not thread safe. What about server session? Is it 
>> thread safe?
>> Thanks Rohit Banga
>>
>>
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Small-clarification-needed-on-server-session-usage-tp31080220p31108240.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top