Hibernate 3.6.7 to 4.0.1 upgrade, nested transactions

3.4k Views Asked by At

I'm trying to upgrade from hibernate 3.6.7 to 4.0.1, and from JDK 1.6 to JDK 1.7.

After migrating configuration files ect ect... I can run my application fine.

First a bit of cfg.xml of my hibernate:

<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory< /property>
<property name="current_session_context_class">thread</property>

But I'm facing 1 a problem with nested sessionFactory.getCurrentSession().beginTransaction() This used to be working in hibernate 3.6.7, though without a "hibernate.transaction.factory_class" property.

Anyone got a clue to what I'm doing wrong?

Stack trace is like this:

org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:350)
at $Proxy4.beginTransaction(Unknown Source)
1

There are 1 best solutions below

0
On

Reading the documentation it looks like Hibernate never supported nested transactions, and that this was enforced in Hibernate 4, since that class AbstractTransactionImpl didn't exist before.

I don't know what you are trying to solve with nested transactions, but maybe there is an alternate way to do it, using only a single one.