• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and the need for JTA

 
Stu Thompson
Hooplehead
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am maintaining / revamping an existing application. It now uses Hibernate 3, Spring 2 and a MySql database. During the switch to H3 I had some error messages that google did not help me solved. ("Unable to locate UserTransaction to check status; nested exception is org.hibernate.TransactionException: Unable to locate UserTransaction to check status")

By removing Hibernate's JTA wiring from the spring web application configuration file, I was able to make the error go away and the application works just fine. ("<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>")

The application is really simple. The DAO classes only perform basic, atomic persistence actions (load(), find(), save(), update(), & delete())

So, the question is do I really need to worry about including a transaction factory in my application? Or am I fine without it? I prefer things rather minimalist and would like to scrape the JTA.

Thanks for your input,

Stu
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate requires a transaction so that it knows when to send its queries to the database. Whether it is JTA, provided by the App Server, or home grown, Hibernate needs it.

Basically Hibernate waits till you commit your transaction to send queries to the database (except load queries), and that way it can send them as prepared statements, and also use JDBC Batch statements to help boost performance.

Mark
 
Stu Thompson
Hooplehead
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for the detailed answer. Just one more question: since I have removed the JTA reference in my conf files, and the application is working, does that mean that hibernate has entered a default configuration with a transaction provider?

thanks again,

Stu
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The cool thing is that Hibernate comes with a "built in' Transaction. So if there is no JTA or other third party Transaction it uses one internally on its own.

Mark
 
Stu Thompson
Hooplehead
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent. Thanks again.

If I have some time I'll get more into this. (hahahaha...who am I kidding???)

Stu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic