user1354825
user1354825

Reputation: 1521

Do Jpa methods execute with or without transactions by default?

I am using JPA with hibernate for mysql.

I want to know whether jpa query methods will execute with or without transaction by default.

I am not using transaction management or locking of any sort.

Authoritative reference will be appreciated.

Thank you !

Upvotes: 1

Views: 888

Answers (2)

ChS
ChS

Reputation: 67

The individual jpa methods can be transactional, but if your logic uses several of these methods(several read/write operations) and you want them to run as an atomic operation in a multithreaded environment, you would still need to make the logic/method transactional to achieve that.

Upvotes: 1

Asgar
Asgar

Reputation: 2422

JPA with hibernate by default uses transaction. to be very precise it uses, @TransactionAttribute(TransactionAttributeType.REQUIRED) . If any other TransactionAttributeType is not defined explicitly, this is what you get by default. To learn more refer to this oracle

Upvotes: 1

Related Questions