-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Hibernate with Transaction Manager and Caching
PostPosted: Thu Feb 28, 2008 6:16 pm 
Newbie

Joined: Mon Jan 07, 2008 3:58 pm
Posts: 7
My company is fairly new to using Hibernate beyond a basic tool for mapping java classes to the database. We're currently running a clustered Linux Apache/Tomcat5.5 environment with an AS400 backend. The application that I'm working on now is using Transactions, which we've never used prior to my pushing for it due to the extra little bit of setup and maintenance required on the AS400 backend. Since I'm only accessing one datasource I am not using a Transaction Manager. Technically I'm using the HibernateTransationManager provided by Spring 2.5 which seems to be working just fine with only the one datasource, so my transactions are just using the default direct JDBC transactions.

The following is a part of the message that I see during Tomcat's startup:
Code:
2008-02-28 15:39:32,500 INFO [org.hibernate.transaction.TransactionFactoryFactory] - <Using default transaction strategy (direct JDBC transactions)>
2008-02-28 15:39:32,500 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - <No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)>


In order to be able to use a read-write or transactional second-level cache, is it required to use an actual Transaction Manager?

Thanks for any suggestions.


Top
 Profile  
 
 Post subject: Re: Hibernate with Transaction Manager and Caching
PostPosted: Thu Feb 28, 2008 6:21 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
set hibernate.transaction.manager_lookup_class to org.hibernate.transaction.JDBCTransactionFactory and you should be good.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 6:32 pm 
Newbie

Joined: Mon Jan 07, 2008 3:58 pm
Posts: 7
I've tried that before without success. I did just now again too after reading your suggestion to get the error that I've gotten before:

Code:
2008-02-28 16:29:32,437 INFO [org.hibernate.transaction.TransactionFactoryFactory] - <Using default transaction strategy (direct JDBC transactions)>
2008-02-28 16:29:32,437 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - <instantiating TransactionManagerLookup: org.hibernate.transaction.JDBCTransactionFactory>
2008-02-28 16:29:32,468 ERROR [org.hibernate.transaction.TransactionManagerLookupFactory] - <Could not instantiate TransactionManagerLookup>
java.lang.ClassCastException: org.hibernate.transaction.JDBCTransactionFactory cannot be cast to org.hibernate.transaction.TransactionManagerLookup
   at org.hibernate.transaction.TransactionManagerLookupFactory.getTransactionManagerLookup(TransactionManagerLookupFactory.java:41)
   at org.hibernate.cfg.SettingsFactory.createTransactionManagerLookup(SettingsFactory.java:422)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:140)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 6:36 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
my bad, it should be hibernate.transaction.factory_class. however, you are not in a JTA environment in the first place so you don't need to worry about that.


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 6:37 pm 
Newbie

Joined: Mon Jan 07, 2008 3:58 pm
Posts: 7
I should have thought about that for a second before responding. org.hibernate.transaction.JDBCTransactionFactory is the setting for hibernate.transaction.factory_class it's not a manager lookup class. Which is why that exception is thrown.

Since I'm using transactions, do I need to be working toward using the transactional caching strategy or towards a read-write strategy?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 6:39 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
dvestal wrote:
I should have thought about that for a second before responding. org.hibernate.transaction.JDBCTransactionFactory is the setting for hibernate.transaction.factory_class it's not a manager lookup class. Which is why that exception is thrown.

Since I'm using transactions, do I need to be working toward using the transactional caching strategy or towards a read-write strategy?


The reason you get that message is that Hibernate should update its cached data only when it knows the transaction has succeeded and it needs to be synchronized with the transaction manager. Your solution is not in a JTA environment and hibernate knows when to update its L2 cache so you don't need to worry about that warning. sorry for the first message;P


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 7:50 pm 
Newbie

Joined: Mon Jan 07, 2008 3:58 pm
Posts: 7
Do I understand correctly then that I need to implement a Transaction Manager in order to be in a JTA environment and therefore be able to use the L2 cache?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 9:05 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
dvestal wrote:
Do I understand correctly then that I need to implement a Transaction Manager in order to be in a JTA environment and therefore be able to use the L2 cache?



No, you can use L2 cache in a plain jdbc environment too. However, if you are in a JTA environment you need to hookup hibernate with the transaction manager so that it will be able to synchronize its state with the transaction manager.



Farzad-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.