hibernate - JPA / JTA / @Transactional Spring annotation -


I'm reading transaction management using Spring Framework. In the first assembly I used Spring + Hibernant and used the Hibernate API to control the transaction (HBINET API). After this, I wanted to test using the @transaction annotation, and it used to work.

I am confused:

  1. Two JPA, JTA, being in Hibernation is the "own" way of managing your transactions. For example, if I use Spring + Hibernate, think about whether you will use "JPA" transaction?

    As we have JA, is it true that we can use spring and jta to control the transaction?

  2. @transaction annotation, is it specific for the Spring Framework? What I explained, this interpretation is Spring Framework, if it is correct, then what is the transaction by using the JPA / JTA to control @transactional

I read online to clear my doubts, although some do not get me a direct answer. Any information will be very helpful.

@ In case of behavior spring-> hibernate using JPA or.

@transactional comments should be kept around all inseparable operations.

then gives example:

We have 2 models i.e. country and city . Like a relational mapping of the country and city models, there can be several cities in one country, so it's like mapping,

  @OneToMany (Fetch = FetchType .LAZY, mapped = "country") Private set & lt; City & gt; Cities;  

Here the country was mapped to many cities so that they could be brought to the corpse, here the role of @transactinal is played, If we get from the database, we will get all the data of the country, but the set of cities will not be available because we are bringing the city to the charming

  // get a non-transient public country (country) = Country Repository.Det Country (); // // has been discontinued after getting country asset connection between country repository and database}  

When we want to access the set of cities from the country's object, then we The set will get zero values ​​because with the set of the set object created, the value of this set is not started so that we can get the value of the experiment, ie @transangal

  // with @transactional @transies Le Public Country Guest Country () {nations = country Ripojitrikdet country (); // When we initialize the cities using the object country, then communicate directly with the database and retrieve all the cities from the database, this is due to the @ Transactical Object Object = country.getCities () is. Shape (); }  

then the original @transaction service can make many calls without having to close the connection with the endpoint in a single transaction < / Strong>.

Hope this will be helpful to you.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -