Methods Summary |
---|
public org.hibernate.Session | getHibernateSession()
EntityManager persistenceContext = getPersistenceContext();
if (persistenceContext instanceof HibernateEntityManager )
{
return ((HibernateEntityManager) persistenceContext).getSession();
}
throw new RuntimeException("ILLEGAL ACTION: Not a Hibernate persistence provider");
|
public javax.persistence.EntityManager | getPersistenceContext()
StatefulBeanContext beanContext = StatefulBeanContext.currentBean.get();
EntityManager persistenceContext = beanContext.getExtendedPersistenceContext(identity);
if (persistenceContext == null)
throw new RuntimeException("Unable to determine persistenceContext: " + identity
+ " in injected SFSB: " + beanContext.getContainer().getObjectName());
return persistenceContext;
|
public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
String methodName = method.getName();
if ( "getPersistenceContext".equals( methodName ) ) {
return getPersistenceContext();
}
else if ( "close".equals( methodName ) ) {
throw new IllegalStateException("It is illegal to close an injected Hibernate Session");
}
else {
//catch all
try {
return method.invoke( getHibernateSession(), args );
}
catch ( InvocationTargetException e ) {
if ( e.getTargetException() instanceof RuntimeException ) {
throw ( RuntimeException ) e.getTargetException();
}
else {
throw e;
}
}
}
|