I'm lost, I can't get working what seems to be very easy.
I want Hibernate to hook on to the transaction of a CMT stateless session bean. I set transactions to RequiresNew, like:
Code:
<ejb-jar>
<description>Verlanglijstje</description>
<display-name>Verlanglijstje</display-name>
<enterprise-beans>
<session id="Verlanglijstje">
<display-name>Verlanglijstje</display-name>
<ejb-name>Verlanglijstje</ejb-name>
<home>nl.kransen.verlanglijstje.service.VerlanglijstjeServiceHome</home>
<remote>nl.kransen.verlanglijstje.service.VerlanglijstjeService</remote>
<ejb-class>nl.kransen.verlanglijstje.service.VerlanglijstjeServiceEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<description></description>
<method>
<ejb-name>Verlanglijstje</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
So all methods get a fresh CMT transaction.
I have the following hibernate propeties:
Code:
hibernate.session_factory_name = java:comp/env/hibernate/SessionFactory
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql = false
hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost:5432/jboss
hibernate.connection.username = jboss
hibernate.connection.password = jboss
hibernate.c3p0.min_size = 5
hibernate.c3p0.max_size = 20
hibernate.c3p0.timeout = 1800
hibernate.c3p0.max_statements = 50
hibernate.cache.provider_class = org.hibernate.cache.EhCacheProvider
hibernate.cache.use_minimal_puts = false
# transactions
hibernate.transaction.factory_class = org.hibernate.transaction.CMTTransactionFactory
hibernate.transaction.manager_lookup_class = org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.transaction.flush_before_completion = true
hibernate.transaction.release_mode = auto
hibernate.transaction.auto_close_session = true
I think I did everything that was described in any documentation on this that I found.
In my bean, I use something like (shortened):
Code:
Session session =
new Configuration()
.configure()
.addClass(Gebruiker.class)
.addClass(Wens.class)
.buildSessionFactory().getCurrentSession();
session.save(someobject);
In the logging, I can see a org.hibernate.SQL log, which mentions an INSERT of the object, but it is not propagated to the database. I tried surrounding Transaction demarcation code or flush/close the Session (though neither should be necessary). What am I missing? I am using JBoss 4.0.1, PostgreSQL 8.0.2, Hibernate 3.0.2. I assumed that the transaction in a CMT is committed when using a RequiresNew after a method returns, is that right? Or should I mark somewhere to commit every method call?
I am totally lost, hope that someone can help me.