PDA

View Full Version : :mad: Problem with HibernateTransactionManager



jccanova
Jul 27th, 2009, 09:32 PM
:mad:

Hi , Im just getting mad with this HibernateTransacitonManager and Hibernate heheheh

I marked the problem... I did the configuration of the TransacionManager with tx:annotationDriven by the book .... and so far so good... Problem is that Hibernate is insisting to commit the transaction.... i guess something is missing.... Jurgen Hoeller could help in this 1.. :P .....
anyway...

Best Regards,

JC.



I dont want that hibernate manage any JdbcConnection for me how i can disable this?


31511219 [main] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Clearing transaction synchronization
31511219 [main] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@5 fbbf3] for key [org.hibernate.impl.SessionFactoryImpl@15023d2] from thread [main]
23211219 [main] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@5 fbbf3] for key [org.hibernate.impl.SessionFactoryImpl@15023d2] from thread [main]
23211219 [main] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHold er@43b5bb] for key [org.apache.commons.dbcp.PoolingDataSource@476914] from thread [main]
23211219 [main] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHold er@43b5bb] for key [org.apache.commons.dbcp.PoolingDataSource@476914] from thread [main]
23211297 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Resetting isolation level of JDBC Connection [jdbc:jtds:sybase://172.19.11.67:5100/GDBRWRPR;useLOBs=false;TDS=4.2, UserName=SBAW0001, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] to 2
19311297 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Resetting isolation level of JDBC Connection [jdbc:jtds:sybase://172.19.11.67:5100/GDBRWRPR;useLOBs=false;TDS=4.2, UserName=SBAW0001, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] to 2
19311360 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransa ctionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@e9c592] after transaction
73011360 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransa ctionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@e9c592] after transaction
73011360 [main] DEBUG org.springframework.orm.hibernate3.SessionFactoryU tils - Closing Hibernate Session
78911360 [main] DEBUG org.springframework.orm.hibernate3.SessionFactoryU tils - Closing Hibernate Session
78911360 [main] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
46411360 [main] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
46411360 [main] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
32511360 [main] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
32511375 [main] ERROR org.jbpm.graph.def.GraphElement - action threw exception: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
301org.springframework.transaction.TransactionSyst emException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:659)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:732)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:701)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:321)
at

jccanova
Jul 27th, 2009, 10:23 PM
I figured the problem...

Hibernate Recommends for JDBC Manager transactions that connection_release_mode be after_transaction (check - http://docs.jboss.org/hibernate/stable/core/reference/en/html/session-configuration.html) while the HibernateTransactionManager dont let such kind of configuration... throwing an exception ... But if i follow the Spring "by the book" configuration which recommend that the hibernate.connection.release_mode be "on_close" but "on_close" is for JTA - Transaction Manager... what i have to do now... ask my resignation or Configure OpenEjb in Tomcat and put geronimo transactionmanager to work... ? any suggestions ????

Hibernate manual for connection_release_mode.

Specifies when Hibernate should release JDBC connections. By default, a JDBC connection is held until the session is explicitly closed or disconnected. For an application server JTA datasource, use after_statement to aggressively release connections after every JDBC call. For a non-JTA connection, it often makes sense to release the connection at the end of each transaction, by using after_transaction. auto will choose after_statement for the JTA and CMT transaction strategies and after_transaction for the JDBC transaction strategy.

e.g. auto (default) | on_close | after_transaction | after_statement



just check what the exception with (after_transaction) tells....

Caused by: org.springframework.transaction.InvalidIsolationLe velException: HibernateTransactionManager is not allowed to support custom isolation levels: make sure that its 'prepareConnection' flag is on (the default) and that the Hibernate connection release mode is set to 'on_close' (SpringTransactionFactory's default). Make sure that your LocalSessionFactoryBean actually uses SpringTransactionFactory: Your Hibernate properties should *not* include a 'hibernate.transaction.factory_class' property!
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:518)
... 23 more

Regards,

JC

jccanova
Jul 27th, 2009, 11:21 PM
Welll,

I figured the problem... :)

I just created my Hibernate transaction manager fixing 1 single problem :P with original Hibernate transaction manager.
It sems that Hibernate 3.3.1 is commiting the transaction.. The test passed. its working fine... its what i need ...


protected void doCommit(DefaultTransactionStatus status) {
HibernateTransactionObject txObject = (HibernateTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Committing Hibernate transaction on Session [" +
SessionFactoryUtils.toString(txObject.getSessionHo lder().getSession()) + "]");
}
try {
if (txObject.getSessionHolder().getTransaction().isAc tive())
txObject.getSessionHolder().getTransaction().commi t();
}
catch (org.hibernate.TransactionException ex) {
// assumably from commit call to the underlying JDBC connection
throw new TransactionSystemException("Could not commit Hibernate transaction", ex);
}
catch (HibernateException ex) {
// assumably failed to flush changes to database
throw convertHibernateAccessException(ex);
}
}

jccanova
Jul 28th, 2009, 01:30 PM
Hello,

Solved the issue performed the tests with ECLIEMMA and found a solution.
It seems that the transaction advice need a help with some aspects when you have a chain of delegates with same method signature. ..... fixed the problem (and consequently dont need any customization over the hibernate transaction manager)...... using the transactional attribute + some aop...

example as follows.

<!-- AOP ADIVISOR FOR ACTION HANDLERS -->
<aop:config>
<aop:pointcut id="actionHandlerOperations" expression="execution(* org.jbpm.graph.def.ActionHandler.*(..)) &amp;&amp; @annotation(org.springframework.transaction.annota tion.Transactional)"/>
<aop:pointcut id="decisionHandlerOperations" expression="execution(* org.jbpm.graph.node.DecisionHandler.*(..))"/>
<aop:pointcut id="taskHandlerOperations" expression="execution(* org.jbpm.taskmgmt.def.AssignmentHandler.*(..))"/>
<aop:advisor advice-ref="aegisTxAdvice" pointcut-ref="actionHandlerOperations"/>
<aop:advisor advice-ref="aegisTxAdvice" pointcut-ref="decisionHandlerOperations"/>
<aop:advisor advice-ref="aegisTxAdvice" pointcut-ref="taskHandlerOperations"/>
</aop:config>

jccanova
Jul 29th, 2009, 12:17 AM
we are what wee are ....


bil and jurgen must shake hands


let start.;... professor said.... lets do it.... so lets do it.... spring + jboss = unbeatable mosquito said... jump... white is white... process is process.....



a process is the mechanics.... lets draw it....

jccanova
Jul 29th, 2009, 12:18 AM
IM goind mad... i love spring... its freeing my mind.... its nice... very nice.


object is object.


nice