Multiple UserTransactions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multiple UserTransactions

grafzal
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi,

is it possible to have more than one UserTansaction in the same JVM with Hibernate?
The scenario is that we have one Thread updating the DB while another one
only reads. As the transaction should not be shared across threads is it possible to have more then one?

Best regards,

Ingo.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

grafzal
...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

Brett Wooldridge-2
There is only one transaction manager (UserTransaction) per VM, but transactions themselves are associated with a single-thread by default.  So in the case you describe below, there will be two separate transactions, one for each thread.  You do not need two UserTransactions, when each thread calls begin() on the UserTransaction (Hibernate will do this automatically), they will get a transaction that is unique to their thread.

Regards,
Brett


> Hi, 
>
> is it possible to have more than one UserTansaction in the same JVM with Hibernate? 
> The scenario is that we have one Thread updating the DB while another one 
> only reads. As the transaction should not be shared across threads is it possible to have more then one? 

> Best regards, 

> Ingo.


On Tue, Aug 13, 2013 at 10:28 PM, grafzal <[hidden email]> wrote:
...



--
View this message in context: http://bitronix-transaction-manager.10986.n7.nabble.com/Multiple-UserTransactions-tp1505p1506.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

grafzal
Hi Brett,

thank you. That´s what I thought but I am using hsqldb with bitronix.tm.resource.jdbc.lrc.LrcXADataSource. For some reason the one Threads transaction blocks until the other Threads transaction finishes. Is there a way around this? I tried using org.hsqldb.jdbc.pool.JDBCXADataSource but then I get:

bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named jdbc/hsqldb
        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:92)
        at theratools.client.local.hibernate.HibernateUtil.init(HibernateUtil.java:69)
        at theratools.client.local.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:40)
        at theratools.client.local.hibernate.CollectorModule.initModule(CollectorModule.java:51)
        at theratools.client.ApplicationManager.initFramework(ApplicationManager.java:148)
        at theratools.client.ApplicationManager.access$0(ApplicationManager.java:130)
        at theratools.client.ApplicationManager$1.run(ApplicationManager.java:84)
Caused by: bitronix.tm.utils.PropertyException: no writeable property 'driverClassName' in class 'org.hsqldb.jdbc.pool.JDBCXADataSource'
        at bitronix.tm.utils.PropertyUtils.getSetter(PropertyUtils.java:318)
        at bitronix.tm.utils.PropertyUtils.setDirectProperty(PropertyUtils.java:217)
        at bitronix.tm.utils.PropertyUtils.setProperty(PropertyUtils.java:83)
        at bitronix.tm.resource.common.XAPool.createXAFactory(XAPool.java:304)
        at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:63)
        at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:101)
        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:88)
        ... 6 more

Thanks,

Ingo.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

grafzal
This has nothing to do with Bitronix. Sorry...
The table is being locked. Have to find out why, though.

Thanks,

Ingo.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

Brett Wooldridge-2
In reply to this post by grafzal
HSQLDB did not used to support XA, so the LrcXADataSource had to be used.  But it appears that version 2.3 claims it.  If you want to try to use org.hsqldb.jdbc.pool.JDBCXADataSource, you must remove all of your *.driverProperties.* properties when using this datasource.

Brett





On Tue, Aug 13, 2013 at 11:54 PM, grafzal <[hidden email]> wrote:
Hi Brett,

thank you. That´s what I thought but I am using hsqldb with
bitronix.tm.resource.jdbc.lrc.LrcXADataSource. For some reason the one
Threads transaction blocks until the other Threads transaction finishes. Is
there a way around this? I tried using org.hsqldb.jdbc.pool.JDBCXADataSource
but then I get:

bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC
datasource named jdbc/hsqldb
        at
bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:92)
        at
theratools.client.local.hibernate.HibernateUtil.init(HibernateUtil.java:69)
        at
theratools.client.local.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:40)
        at
theratools.client.local.hibernate.CollectorModule.initModule(CollectorModule.java:51)
        at
theratools.client.ApplicationManager.initFramework(ApplicationManager.java:148)
        at
theratools.client.ApplicationManager.access$0(ApplicationManager.java:130)
        at theratools.client.ApplicationManager$1.run(ApplicationManager.java:84)
Caused by: bitronix.tm.utils.PropertyException: no writeable property
'driverClassName' in class 'org.hsqldb.jdbc.pool.JDBCXADataSource'
        at bitronix.tm.utils.PropertyUtils.getSetter(PropertyUtils.java:318)
        at
bitronix.tm.utils.PropertyUtils.setDirectProperty(PropertyUtils.java:217)
        at bitronix.tm.utils.PropertyUtils.setProperty(PropertyUtils.java:83)
        at bitronix.tm.resource.common.XAPool.createXAFactory(XAPool.java:304)
        at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:63)
        at
bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:101)
        at
bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:88)
        ... 6 more

Thanks,

Ingo.



--
View this message in context: http://bitronix-transaction-manager.10986.n7.nabble.com/Multiple-UserTransactions-tp1505p1508.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

grafzal
This seems to work pretty well. Thanks.
i just can´t get rid of the locking behavior. I tried different isolation levels with no luck...

Thanks,
Ingo.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

Brett Wooldridge-2
The default locking for hsqldb is what they call 2-phase locking, what you probably want is their MVCC locking mode.  See this chapter:


If you are not committed to hsqldb, and need a pure Java DB, I recommend Apache Derby.

Brett


On Wed, Aug 14, 2013 at 12:42 AM, grafzal <[hidden email]> wrote:
This seems to work pretty well. Thanks.
i just can´t get rid of the locking behavior. I tried different isolation
levels with no luck...

Thanks,
Ingo.



--
View this message in context: http://bitronix-transaction-manager.10986.n7.nabble.com/Multiple-UserTransactions-tp1505p1511.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple UserTransactions

grafzal
Hi Brett,

Thank you very much. I am going to look into Apache Derby,

Ingo.
Loading...