-
1. Re: shouldn't local-tx-datasource have auto-commit = false?
weston.price Jan 14, 2007 9:20 AM (in response to jhudson)How are you starting your transaction? Are you using EJB, Servlets etc? Also, what version of JBoss are you using?
-
2. Re: shouldn't local-tx-datasource have auto-commit = false?
jhudson Jan 14, 2007 12:59 PM (in response to jhudson)Sorry, I should have provided that information before... thanks very much for the reply.
I'm using hibernate 3.1.3 and jboss-4.0.5 with mysql 5.0.11 and the latest connectorI have a HAR which puts the session factory in the JNDI context <server> <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <depends>jboss.jca:service=DataSourceBinding,name=jdbc/MyAdBox</depends> <attribute name="DatasourceName">java:/jdbc/MyAdBox</attribute> <attribute name="SessionFactoryName">java:/hibernate/MyAdBoxHibernateFactory2</attribute> <attribute name="CacheProviderClass">org.hibernate.cache.OSCacheProvider</attribute> <attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute> <attribute name="QueryCacheEnabled">true</attribute> <attribute name="ShowSqlEnabled">false</attribute> </mbean> </server>
And, this is how I would handle a transaction...Session s = null; Transaction t = null; try { s = getSession(); t = s.beginTransaction() // transactional code here t.commit(); } catch (Throwable throwable) { if (null != t) t.rollback(); } finally { if (null != s) s.close(); }
-
3. Re: shouldn't local-tx-datasource have auto-commit = false?
weston.price Jan 21, 2007 11:06 AM (in response to jhudson)Could you post your *-ds.xm file?
-
4. Re: shouldn't local-tx-datasource have auto-commit = false?
weston.price Jan 21, 2007 11:13 AM (in response to jhudson)Whoops, sorry, I just saw it ;-)
Ok, there are two real choices you have here:
1) Leverage typical JDBC transactions with Hibernate.
By default, Hibernate, if not told otherwise, will use JDBC tranasactions. Being that no CMT is being started in this case, the underlying connection will have it's autoCommit value set to true (as per the JCA specification), regardless of the type of datasource being used. Note, Hibernate may turn this off/on but JBossJCA will not.
2) Use CMT or UserTransactions to begin a transaction and have Hibernate participate in this scheme by correctly configuring Hibernate to use a different TransactionStrategy/Lookup.
Once you do this, JBossJCA will correctly set the autocommit flag on the underlying connection to participate in the global transaction.
Again, I need some more information as to what context are you using Hibernate. Are you doing this from a Servlet, from an EJB etc? -
5. Re: shouldn't local-tx-datasource have auto-commit = false?
weston.price Jan 21, 2007 11:16 AM (in response to jhudson)Note, if you don't want to participate in Global transactions, you can just as easily use the no-txn-datasource. Again, Hibernate will turn on/off autocommit depending upon the context.
-
6. Re: shouldn't local-tx-datasource have auto-commit = false?
advaittrivedi Dec 18, 2007 2:08 AM (in response to jhudson)So, jhudson what was the solution you finally applied to resolve this one. Can you post a code snipped?