hibernatespring-data-jpaspring-transactions

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 !


Solution

  • 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