Hi,
I've tried posting a couple of times (difference subjects) with little (i.e. no) response. so hopefully I get some better luck this time ....
I've a application that is using Hibernate as a JPA provider. Spring is creating the entity manager and also invoking the reference to a WeblogicJtaTransactionManager. I'm deploying the app to a WebLogic 10 server.
The code being run is:
Code:
@Transactional
public void poll() {
Collection<GtTradeLeg> waitingTradeLegs = gtTradeLegDao.findWaiting();
Collection<GtTradeLeg> allowableTradeLegs = filterChain.filter(waitingTradeLegs);
Collation<GtTrade, GtTradeLeg> tradeCollation = tradeLegCollator.collate(allowableTradeLegs);
incomingDealPublisher.publish(tradeCollation.getCollated());
Collection<GtTradeLeg> waitingMultiLegDeals = tradeCollation.getUncollated();
gtTradeLegDao.delete(from(waitingTradeLegs).exclude(waitingMultiLegDeals));
}
The general jist is that a list gets read from the database, gtTradeLegDao.findWaiting(). The list is processed. Some elements are placed onto a JMS queue and then deleted from the database gtTradeLefgDao.delete(...).
All of this works just fine, except that the Hibernate Session is never being flushed, and this the deletion is not being written to the database.
I have tested the flushing by placing another gtTradeLegDao.findWaiting() after the delete(...), which forces the flush. When I do this the deletion is written out correctly. So, this indicates that the Session is not calling flush when the JTATransaction commits.
My transaction/persistence wiring looks as follows:
Code:
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:databasePlatform="org.hibernate.dialect.HSQLDialect"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="datasource"
p:jpaVendorAdapter-ref="jpaVendorAdapter"
p:jpaPropertyMap-ref="jpaPropertyMap"/>
<bean
id="transactionManager"
class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"/>
<util:map id="jpaPropertyMap">
<entry key="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
<entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext"/>
</util:map>
<tx:annotation-driven />
And here is the log trace on debug mode, which clearly highlights that the transaction is being used:
Code:
DEBUG WebLogicJtaTransactionManager - Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@17bb56d]
DEBUG WebLogicJtaTransactionManager - Creating new transaction with name [com.cbaib.gm.gtout.poller.Poller.poll]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
DEBUG TransactionSynchronizationManager - Initializing transaction synchronization
DEBUG WebLogicJtaTransactionManager - Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@c40bf8]
DEBUG WebLogicJtaTransactionManager - Participating in existing transaction
DEBUG EntityManagerFactoryUtils - Opening JPA EntityManager
DEBUG EntityManagerFactoryUtils - Registering transaction synchronization for JPA EntityManager
DEBUG TransactionSynchronizationManager - Bound value [org.springframework.orm.jpa.EntityManagerHolder@edd37b] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@91e124] to thread [DefaultQuartzScheduler_Worker-4]
DEBUG SQL - select gttradeleg0_.temp_id as temp1_0_, gttradeleg0_.action as action0_, gttradeleg0_.autocover as autocover0_, gttradeleg0_.broker_code as broker4_0_, gttradeleg0_.ccy1_amount as ccy5_0_, gttradeleg0_.ccy1_buy_sell as ccy6_0_, gttradeleg0_.ccy1_code as ccy7_0_, gttradeleg0_.ccy2_amount as ccy8_0_, gttradeleg0_.ccy2_code as ccy9_0_, gttradeleg0_.customer_account as customer10_0_, gttradeleg0_.dealt_ccy_code as dealt11_0_, gttradeleg0_.delivery_type as delivery12_0_, gttradeleg0_.cd_deal_id as cd13_0_, gttradeleg0_.forward_settle_date as forward14_0_, gttradeleg0_.insert_time as insert15_0_, gttradeleg0_.inverted_rate_flg as inverted16_0_, gttradeleg0_.entry_type as entry17_0_, gttradeleg0_.login_id as login18_0_, gttradeleg0_.modification_level as modific19_0_, gttradeleg0_.optional_settlement_date as optional20_0_, gttradeleg0_.revision_date as revision21_0_, gttradeleg0_.saved_swap_id as saved22_0_, gttradeleg0_.security_group as security23_0_, gttradeleg0_.settlement_date as settlement24_0_, gttradeleg0_.spot_date as spot25_0_, gttradeleg0_.status as status0_, gttradeleg0_.swap_id as swap27_0_, gttradeleg0_.trade_date as trade28_0_, gttradeleg0_.trade_number as trade29_0_, gttradeleg0_.internal_external_trade as internal30_0_, gttradeleg0_.deal_rate as deal31_0_, gttradeleg0_.deal_type as deal32_0_ from GT_TRAD_DETAILS_FXTG gttradeleg0_
DEBUG WebLogicJtaTransactionManager - Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@1a6699c]
DEBUG WebLogicJtaTransactionManager - Participating in existing transaction
DEBUG TransactionSynchronizationManager - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@edd37b] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@91e124] bound to thread [DefaultQuartzScheduler_Worker-4]
DEBUG SQL - select smalltrade0_.smll_i as smll1_1_ from SMLL smalltrade0_
DEBUG WebLogicJtaTransactionManager - Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@63ef4d]
DEBUG WebLogicJtaTransactionManager - Participating in existing transaction
DEBUG TransactionSynchronizationManager - Bound value [org.springframework.jms.connection.JmsResourceHolder@1ab7a89] for key [weblogic.jms.client.JMSXAConnectionFactory@9b212f] to thread [DefaultQuartzScheduler_Worker-4]
DEBUG JmsTemplate - Executing callback on JMS Session: weblogic.jms.client.WLSessionImpl@f9f3b2
DEBUG JmsTemplate - Sending created message: ObjectMessage[null,com.cbaib.gm.gtout.model.GtTrade@19fa]
DEBUG WebLogicJtaTransactionManager - Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@15c46dd]
DEBUG WebLogicJtaTransactionManager - Participating in existing transaction
DEBUG TransactionSynchronizationManager - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@edd37b] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@91e124] bound to thread [DefaultQuartzScheduler_Worker-4]
DEBUG TransactionSynchronizationManager - Retrieved value [org.springframework.orm.jpa.EntityManagerHolder@edd37b] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@91e124] bound to thread [DefaultQuartzScheduler_Worker-4]
DEBUG WebLogicJtaTransactionManager - Triggering beforeCommit synchronization
DEBUG WebLogicJtaTransactionManager - Triggering beforeCompletion synchronization
DEBUG TransactionSynchronizationManager - Removed value [org.springframework.orm.jpa.EntityManagerHolder@edd37b] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@91e124] from thread [DefaultQuartzScheduler_Worker-4]
DEBUG TransactionSynchronizationManager - Removed value [org.springframework.jms.connection.JmsResourceHolder@1ab7a89] for key [weblogic.jms.client.JMSXAConnectionFactory@9b212f] from thread [DefaultQuartzScheduler_Worker-4]
DEBUG WebLogicJtaTransactionManager - Initiating transaction commit
DEBUG WebLogicJtaTransactionManager - Triggering afterCommit synchronization
DEBUG WebLogicJtaTransactionManager - Triggering afterCompletion synchronization
DEBUG TransactionSynchronizationManager - Clearing transaction synchronization
I obviously don't want to call gtTradeLegDao.findWaiting() to force a flush, it should happen when the transaction is committed. Any help???
Cheers
Ryan