| How to access Hibernate objects from EJB 3.0 ? |
| Written by F.Marchioni | |||||
|
Basically you need to cast objects to Hibernate types. For example: Getting Hibernate SessionYou can get access to the current underlying Hibernate Session by typecasting your reference to EntityManager.:
@PersistenceContext EntityManager entityManager;
public void someMethod();
{
org.jboss.ejb3.entity.HibernateSession hs = (HibernateSession)entityManager;
org.hibernate.Session session = hs.getHibernateSession();
}
Getting Hibernate QueryYou can get access to the current underlying Hibernate Query by typecasting your reference to a org.hibernate.ejb.QueryImpl.
@PersistenceContext EntityManager entityManager;
public void someMethod();
{
javax.persistence.Query query = entityManager.createQuery(...);
org.hiberante.ejb.QueryImpl hs = (QueryImpl)query;
org.hibernate.Query hbQuery = hs.getHibernateQuery();
}
JBoss.org Search
Custom Search
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |


