我们正面临一些与spring @Transactional
有关的问题,我们有一个控制器和一个服务类,尽管服务类没有用@Transactional
标记,实体正在保存。我们使用@EnableTransactionManagement(proxyTargetClass = true)
和OpenEntityManagerInViewInterceptor
也弹簧数据JPA。我想这个信息可能不够,但对这种行为的可能原因有任何了解。实体持久性没有@Transactional的实体得到保存
2016-01-07 20:58:15,393 DEBUG [org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource] (default task-23) Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
2016-01-07 20:58:15,393 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (default task-23) Creating new transaction with name [org.springframework.data.envers.repository.support.EnversRevisionRepositoryImpl.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
2016-01-07 20:58:15,394 DEBUG org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (default task-23) Skipping JTA sync registration due to auto join checking
2016-01-07 20:58:15,394 DEBUG [org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (default task-23) Skipping JTA sync registration due to auto join checking
2016-01-07 20:58:15,394 DEBUG [org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (default task-23) successfully registered Synchronization
2016-01-07 20:58:15,394 DEBUG [org.hibernate.jpa.spi.AbstractEntityManagerImpl] (default task-23) Looking for a JTA transaction to join
2016-01-07 20:58:15,394 DEBUG org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler] (default task-23) Joined JTA transaction
2016-01-07 20:58:15,394 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory] (default task-23) Returning cached instance of singleton bean 'jpaAuditingHandler'
2016-01-07 20:58:15,417 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (smsQueueListenerBean-1) Initiating transaction commit
2016-01-07 20:58:15,417 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (smsQueueListenerBean-1) Creating new transaction with name [smsQueueListenerBean]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2016-01-07 20:58:15,418 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (emailQueueListenerBean-1) Initiating transaction commit
2016-01-07 20:58:15,418 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (emailQueueListenerBean-1) Creating new transaction with name [emailQueueListenerBean]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2016-01-07 20:58:15,459 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (default task-23) Participating in existing transaction
2016-01-07 20:58:15,459 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (default task-23) Participating in existing transaction
2016-01-07 20:58:15,460 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (default task-23) Obtaining JDBC connection
2016-01-07 20:58:15,461 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (default task-23) Obtained JDBC connection
2016-01-07 20:58:15,463 DEBUG [org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl] (default task-23) Starting ResultSet row #0
2016-01-07 20:58:15,463 DEBUG [org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl] (default task-23) On call to EntityIdentifierReaderImpl#resolve, EntityKey was already known; should only happen on root returns with an optional identifier specified
2016-01-07 20:58:15,464 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (default task-23) Releasing JDBC connection
2016-01-07 20:58:15,465 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (default task-23) Released JDBC connection
你可以把一些类代码,JavaConfig,...? – Zava
这是因为,正如您所说的,您正在使用'OpenEntityManagerInViewInterceptor'在执行控制器中的代码之前打开事务。或者它不是? –
你确定你在调用堆栈中没有@Transactional注解的方法吗? –