user1997254
user1997254

Reputation: 25

Hibernate, Spring and JTA support

I am building a web-application that is related to domain where 200-500 user(request) to only save data per second. I choose spring, Hibernate, Jboss. But when I learn about Spring and Hibernate integration, spring doc says about some JTA term again and again.

So now question.

  1. I read something about JTA but little confusion, Is this JTA means distributed transaction? If above question's answer yes, then what is distributed transaction? For me distributed transaction - Transaction which are performed in different machine. (Is this possible? Means why transaction will be happened on different machine as they are only unit of work)

  2. Why hibernate and Spring cares about JTA (any real time example).

  3. Why should I care about JTA if I have hibernate?( If my database on remote location(not on local), then should I care, Right? But why?( Please explain)

  4. How JTA help to achieve good performance?

  5. What is JTA and NON-JTA transaction?

Thanks in advance and please help me out, I am little new and confused about these tech. Thanks again.

Upvotes: 0

Views: 575

Answers (1)

Brian
Brian

Reputation: 902

Regarding your questions:

  1. Java Transaction API (JTA) supports distributed transactions in a single application (even multiple EARs or WARs in one application server is technically still one application, because there's only one instance of the server serving all of the EARs or WARs). A distributed transaction is, roughly speaking, a mechanism to enable a theoretically unlimited number of operations across several enterprise information systems (EIS) in an atomic way - all operations or none apply, not just some.

    Your understanding of distributed transactions is not quite right. It has nothing to do with the fact that different machines could be involved, it rather boils down to having multiple EISs involved.

    Let's say you have two databases and for each one you have one persistence unit (in JPA). Now you perform some work in your application. From your application's point of view it's just one unit of work, but for your databases it's one unit of work each. And this is usually coordinated using JTA in an application server.

  2. Hibernate and Spring care about JTA, because both are just frameworks which enable developers to develop applications efficiently.

    For an example, see the one above. If Hibernate and Spring were to impede distributed transactions, believe me, the projects would die due to a lack of users.

  3. You needn't really care about JTA if you have only one database, because then it'd suffice to use "NON-JTA" transactions, which are resource local (where resource means your database and local means limited to your database).

  4. JTA does not help to achieve good performance in any way. It's just a specification for managing distributed transactions in one application.

  5. I think you know the answer to this one by now. ;)

Upvotes: 1

Related Questions