Im working on developing a webapplication with MySQL Server 5.1, Spring 3.0.5 and Hibernate 3.6. I use Springs Transaction Management. Im a newbie, so please be patient with me if I ask a question which is easy to answer. :-)
1) I read about global (xa) and local transactions. Is it correct, that global transactions mean transactions, which execute dataoperations on different resources (like different databases). And that local transactions execute dataoperations on only one resource (database).?
2) Is it possible to have global transactions with Hibernate? In the Spring Reference Documentation I read this: "You can also use Hibernate local transactions easily, as shown in the following examples. In this case, you need to define a Hibernate LocalSessionFactoryBean, which your application code will use to obtain Hibernate Session instances." Thats why I think that Hibernate transactions are maybe always local and I did not find anything else about it.
3) Why is it possible to use MyISAM tables with Hibernate? They dont support Transactions and I think Hibernate requires Transactions? I really don't understand this. At first I thought it wouldn't be possible - but why is it then possible to create MyISAM Tables with Hibernate and use a MyISAM Dialect? How does this work??? Does Hibernate require transaction or doesnt it? I thought for using Hibernate you need to use InnoDB.
Thanks for answering! :-)
Yes, JTA, the API for XA transactions in Java, uses a two-phase commit protocol to perform global transactions. If you need to ensure transaction consistency over multiple resources, JTA is the proper tool in Java.
Hibernate does work with JTA. It is quite a bit harder to set up than plain vanilla resource local transactions, generally uses more resources due to the nature of two-phase commit, and the implementation quality varies between database vendors and drivers, so only use it if you have to. (For example, JTA kinda sorta works with MS SQL Server, but this functionality is only glued on through a set of stored procedures. Other resources may not support all of the standard, for example not allow a transaction to be paused and later resumed. If you don't need it, save yourself the trouble.)
You can use MyISAM with Hibernate, but transactions won't work. Hibernate will start and commit transactions normally, which the MyISAM storage engine will ignore silently, so everything will go straight to disk. Use the default storage engine, InnoDB, unless you have a reason not to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With