java - Accessing Hibernate Session from EJB using EntityManager -


is possible obtain hibernate session object entitymanager? want access hibernate specific api...

i tried like:

org.hibernate.session hsession =    ( (entitymanagerimpl) em.getdelegate() ).getsession(); 

but invoke method in ejb "a system exception occurred during invocation on ejb" nullpointerexception

i use glassfish 3.0.1

bozho , partenon correct, but:

in jpa 2, preferred mechanism entitymanager.unwrap(class)

hibernateentitymanager hem = em.unwrap(hibernateentitymanager.class); session session = hem.getsession(); 

i think exception caused because trying cast implementation class (perhaps dealing jdk proxy). cast interface, , should fine (in jpa 2 version, no casting needed).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -