-->
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.  [ 3 posts ] 
Author Message
 Post subject: EntityManager and sessionfactory newbie question
PostPosted: Sat Nov 28, 2009 3:45 am 
Newbie

Joined: Sat Nov 28, 2009 3:37 am
Posts: 2
Hi,
I am just wondering what are the relations between sessionfactory and entitymanager. When using entitymanager in a container managed env. eg. using persistance.xml, will the entitymanager make use of the sessionfactory(is the entitymanager just a layer that makes use of the sessionfactory)? I was always used to using hibernate through the sessions, and my concern is if there will be any loss in performance/cache when using entitymanager instead of sessionfactory etc.

BR Soelvar


Top
 Profile  
 
 Post subject: Re: EntityManager and sessionfactory newbie question
PostPosted: Mon Nov 30, 2009 9:01 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Look in the code if you're really interested, it's very straight forward. If you print out the class of your EntityManager you've been given by your container, you'll most likely find it's an org.hibernate.ejb.EntityManagerImpl, which is just a light wrapper around the Hibernate Session. Same deal for EntityManagerFactoryImpl and SessionFactory.

TL;DR
EntityManager == Session
EntityManagerFactory == SessionFactory.


Top
 Profile  
 
 Post subject: Re: EntityManager and sessionfactory newbie question
PostPosted: Mon Nov 30, 2009 3:14 pm 
Newbie

Joined: Sat Nov 28, 2009 3:37 am
Posts: 2
Thanks for the reply Stolley,

So if I am understanding correctly, then with EntityManager you get the same benefits as when using Session, and the object obtained from queries are pojos instead of hibernate cglib wrapped non serializable classes, which kind of makes dto/vo obsolete - almost makes me wonder why anyone would use session/sessionFactory.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.