-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Implications of sharing an entity manager in a web app...
PostPosted: Tue Apr 10, 2007 9:42 am 
Newbie

Joined: Thu Apr 05, 2007 5:57 am
Posts: 10
Hello,

I would like to put an entity manager instance into the ServletContext/application scope of a web application.

The reason for this is that I want to cache the results of a query (I want to use the query cache) and it seems that I need to put the entity manager either in session or in application scope in order for the query cache to work.

Now I am VERY worried about the thread safety issues or the perfomance issues of having only one entity manager instance for use by several clients.

My questions are therefore as follows:

-What are the implications regarding thread safety of having a single entity manager for use by several clients?
-What are the potential performance issues of having a single entity manager for use by several clients?
-If the solution of having one EM per web app is not feasible, then what other solution do you advise in order to be able to take advantage of the query cache?

Any clue welcome,

Thanks in advance,

Julien.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:28 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
EM is not thread safe do don't do that.
To cache a query, you need to activate the query cache in the config (check the Hibernate reference doc) and use query.setCacheable(true)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.