Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring JtaTransactionManager is not flushing during before completion phase when using Hibernate 4 or Hibernate 3 [SPR-9424] #14060

Closed
spring-projects-issues opened this issue May 18, 2012 · 1 comment
Labels
in: data status: duplicate

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 18, 2012

Alysson Rodrigues opened SPR-9424 and commented

Hibernate 4.1.0.Final isn´t auto flushing during before completion phase when using JTA (CMT) under Spring 3.1.1.RELEASE and JBoss AS 7.1.

I´ve set hibernate.transaction.factory_class to org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory and hibernate.transaction.jta.platform to org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform. My transaction manager bean is a org.springframework.transaction.jta.JtaTransactionManager configured bean.

Then, logging (TRACE mode) shows me the following info:

15:23:58,555 TRACE [org.springframework.transaction.interceptor.TransactionInterceptor] (http--127.0.0.1-8080-1) Completing transaction for...

15:23:58,557 TRACE [org.springframework.transaction.jta.JtaTransactionManager] (http--127.0.0.1-8080-1) Triggering beforeCommit synchronization
15:23:58,558 TRACE [org.springframework.transaction.jta.JtaTransactionManager] (http--127.0.0.1-8080-1) Triggering beforeCompletion synchronization
15:23:58,559 DEBUG [org.springframework.orm.jpa.EntityManagerFactoryUtils] (http--127.0.0.1-8080-1) Closing JPA EntityManager
15:23:58,560 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (http--127.0.0.1-8080-1) Initiating transaction commit
15:23:58,561 TRACE [org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization] (http--127.0.0.1-8080-1) JTA sync : beforeCompletion()
15:23:58,562 TRACE [org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl] (http--127.0.0.1-8080-1) Transaction before completion callback
15:23:58,564 TRACE [org.hibernate.internal.SessionImpl] (http--127.0.0.1-8080-1) before transaction completion
15:23:58,566 TRACE [org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization] (http--127.0.0.1-8080-1) JTA sync : afterCompletion(3)
15:23:58,567 TRACE [org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl] (http--127.0.0.1-8080-1) Transaction after completion callback [status=3]
15:23:58,568 TRACE [org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (http--127.0.0.1-8080-1) after transaction completion
15:23:58,569 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--127.0.0.1-8080-1) Aggressively releasing JDBC connection
15:23:58,570 TRACE [org.hibernate.internal.SessionImpl] (http--127.0.0.1-8080-1) after transaction completion
15:23:58,571 DEBUG [org.hibernate.ejb.EntityManagerImpl] (http--127.0.0.1-8080-1) Closing entity manager after transaction completion
15:23:58,572 TRACE [org.hibernate.internal.SessionImpl] (http--127.0.0.1-8080-1) Closing session
15:23:58,573 TRACE [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--127.0.0.1-8080-1) Closing logical connection
15:23:58,574 TRACE [org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler] (http--127.0.0.1-8080-1) Handling invocation of connection method [close]
15:23:58,575 TRACE [org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler] (http--127.0.0.1-8080-1) Invalidating connection handle
15:23:58,576 TRACE [org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl] (http--127.0.0.1-8080-1) Closing JDBC container [org.hibernate.engine.jdbc.internal.JdbcResourceRegistryImpl@17072bf]
...

HOWEVER, IF I use org.springframework.orm.jpa.JpaTransactionManager, instead of JtaTransactionManager, adjusting the configurations above, logging shows me:

16:40:36,014 TRACE [org.springframework.transaction.interceptor.TransactionInterceptor] (http--127.0.0.1-8080-1) Completing transaction for...

16:40:36,015 TRACE [org.springframework.orm.jpa.JpaTransactionManager] (http--127.0.0.1-8080-1) Triggering beforeCommit synchronization
16:40:36,015 TRACE [org.springframework.orm.jpa.JpaTransactionManager] (http--127.0.0.1-8080-1) Triggering beforeCompletion synchronization
16:40:36,016 DEBUG [org.springframework.orm.jpa.JpaTransactionManager] (http--127.0.0.1-8080-1) Initiating transaction commit
16:40:36,016 DEBUG [org.springframework.orm.jpa.JpaTransactionManager] (http--127.0.0.1-8080-1) Committing JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@2d885a]
16:40:36,017 DEBUG [org.hibernate.engine.transaction.spi.AbstractTransactionImpl] (http--127.0.0.1-8080-1) committing
16:40:36,017 TRACE [org.hibernate.internal.SessionImpl] (http--127.0.0.1-8080-1) Automatically flushing session
16:40:36,017 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Flushing session
16:40:36,018 DEBUG [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Processing flush-time cascades
16:40:36,018 TRACE [org.hibernate.engine.internal.Cascade] (http--127.0.0.1-8080-1) Processing cascade ACTION_PERSIST_ON_FLUSH for: br.gov.tcu.sgos.modelo.entidade.ordemservico.OrdemServico
16:40:36,019 TRACE [org.hibernate.engine.spi.CascadingAction] (http--127.0.0.1-8080-1) Cascading to persist on flush: br.gov.tcu.sgos.modelo.entidade.contrato.Contrato
16:40:36,020 TRACE [org.hibernate.engine.internal.Cascade] (http--127.0.0.1-8080-1) Done processing cascade ACTION_PERSIST_ON_FLUSH for: br.gov.tcu.sgos.modelo.entidade.ordemservico.OrdemServico
16:40:36,021 DEBUG [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Dirty checking collections
16:40:36,021 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Flushing entities and processing referenced collections
16:40:36,022 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (http--127.0.0.1-8080-1) br.gov.tcu.sgos.modelo.entidade.ordemservico.OrdemServico.descricao is dirty
16:40:36,022 TRACE [org.hibernate.event.internal.DefaultFlushEntityEventListener] (http--127.0.0.1-8080-1) Found dirty properties [[br.gov.tcu.sgos.modelo.entidade.ordemservico.OrdemServico#5]] : [Ljava.lang.String;@1882506
16:40:36,023 TRACE [org.hibernate.event.internal.DefaultFlushEntityEventListener] (http--127.0.0.1-8080-1) Updating entity: [br.gov.tcu.sgos.modelo.entidade.ordemservico.OrdemServico#5]
16:40:36,024 TRACE [org.hibernate.engine.internal.Versioning] (http--127.0.0.1-8080-1) Incrementing: 2 to 3
16:40:36,026 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Processing unreferenced collections
16:40:36,026 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Scheduling collection removes/(re)creates/updates
16:40:36,027 DEBUG [org.hibernate.event.internal.AbstractFlushingEventListener] (http--127.0.0.1-8080-1) Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects

SO, is something missing? Some additional configuration? Using JpaTransactionaManager everything works as expected, but when using JtaTransactionManager there is no auto flush during the before completion phase.

Could you please help me?

I´m looking forward to hearing good news from you.

Thank you.


Affects: 3.1.1

Issue Links:

  • #14040 Session not flushed with Hibernate 4.1.3, JTA and Spring transaction management integration ("duplicates")
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 4, 2012

Chris Beams commented

Appears to be a duplicate of #14040.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data status: duplicate
Projects
None yet
Development

No branches or pull requests

1 participant