-->
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.  [ 1 post ] 
Author Message
 Post subject: JPA portable retrieval of Hibernate's Session from EntityMan
PostPosted: Wed Feb 11, 2009 8:04 am 
Newbie

Joined: Sun Dec 07, 2008 1:29 pm
Posts: 6
hi,

I have the following dependencies: Hibernate, Hibernate-EntityManager and OpenEJB latest implementation.

In one of my Container Managed Dao implementations I have the snippet below which is the way to get the underlying Hibernate Session from the
EntityManager injected by the container (note the double level of indirection 2x getDelegate). My question is how portable is this code? if I
wish to use now lets say JBoss or Oracle AS or WebSphere would this code remain unchanged or there would be a different way?

Many thanks in advance,
Best regards,
Giovanni

//--------------------------------------------------------------------
@PersistenceContext(unitName = "movie-unit",
type = PersistenceContextType.EXTENDED)
public void
setEntityManager(EntityManager anEntityManager)
{
EntityManager myActualEntityManager = anEntityManager.getDelegate();

Object myActualSession = myActualEntityManager.getDelegate();

return myActualSession;
}


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

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.