I've got the same problem - session not flushed when transaction commits. I think session.flush() needs to be added into org.jboss.hibernate.session.TransactionSynch.beforeCompletion()
public void beforeCompletion() {
try {
session.flush();
} catch (HibernateException e) {
log.error("Could not flush session on end of transaction", e);
}
}
Besides this, there's one more problem here. It's all fine when only EjbInterceptor is configured in container-configuration (providing session.flush() is added).
But when I configure also servlet filter (exactly following Wiki instructions) it all get wrong. For example, when I deploy my ear with ejb & web modules:
1. Container deploys EJB module.
2004-08-16 13:48:59,543 DEBUG [org.jboss.hibernate.session.EjbInterceptor] Configuring EjbInterceptor [service=jboss.har:service=Hibernate, scope=transaction]
SessionContext.prepareSessionFactory("java:/hibernate/SessionFactory", Scope.TRANSACTION) called here.
2. Container installs servlet filter.
2004-08-16 14:02:42,418 DEBUG [org.jboss.hibernate.session.FilterInterceptor] Configuring FilterInterceptor [service=jboss.har:service=Hibernate, scope=thread]
SessionContext.prepareSessionFactory("java:/hibernate/SessionFactory", Scope.THREAD) called here which overrides scope for this jndiName in scopes Hashtable.
3. I call an ejb from my scheduled service (NOT from a servlet). In ejb I get a session: SessionContext.getSession("java:/hibernate/SessionFactory") and I given a session with scope THREAD and which is not enlisted in transaction! this is not correct behaviour for ejb.
Code:
Code: