Hibernate 3.6.7 到 4.0.1 升级,嵌套事务
我正在尝试从 hibernate 3.6.7 升级到 4.0.1,从 JDK 1.6 升级到 JDK 1.7。
迁移配置文件等后...我可以正常运行我的应用程序。
首先是我的休眠状态的 cfg.xml:
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory< /property>
<property name="current_session_context_class">thread</property>
但我面临 1 嵌套 sessionFactory.getCurrentSession().beginTransaction() 的问题 这曾经在 hibernate 3.6.7 中工作,尽管没有“hibernate.transaction.factory_class”属性。
有人知道我做错了什么吗?
堆栈跟踪是这样的:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读文档,Hibernate 似乎从不支持嵌套事务,并且这是在 Hibernate 4 中强制执行的,因为该类 AbstractTransactionImpl 以前不存在。
我不知道您想通过嵌套事务解决什么问题,但也许有另一种方法可以做到这一点,即仅使用一种方法。
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.