When you mark your method as @Transactional
, occurrence of any exception inside your method will mark the surrounding TX as roll-back only (even if you catch them). You can use other attributes of @Transactional
annotation to prevent it of rolling back like:
@Transactional(rollbackFor=MyException.class, noRollbackFor=MyException2.class)
More Related Contents:
- Why does Hibernate disable INSERT batching when using an IDENTITY identifier generator
- Spring, JPA, and Hibernate – how to increment a counter without concurrency issues
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Bypass GeneratedValue in Hibernate (merge data not in db?)
- How does the FetchMode work in Spring Data JPA
- How to fetch FetchType.LAZY associations with JPA and Hibernate in a Spring Controller
- No Dialect mapping for JDBC type: 1111
- @Transactional method called from another method doesn’t obtain a transaction
- Correct use of flush() in JPA/Hibernate
- How to set up default schema name in JPA configuration?
- What is the ‘best’ way to do distributed transactions across multiple databases using Spring and Hibernate
- Spring data JPA and hibernate detached entity passed to persist on ManyToMany relationship
- Can I combine a @Query definition with a Specification in a Spring Data JPA repository method?
- Do you need a database transaction for reading data?
- When are connections returned to the connection pool with Spring JPA (Hibernate) Entity Manager?
- Change database schema during runtime based on logged in user
- How to map sql native query result into DTO in spring jpa repository?
- Difference between save and saveAndFlush in Spring data jpa
- The onFlushDirty Hibernate Interceptor method is never called
- javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional
- spring data jpa @query and pageable
- How to rollback a database transaction when testing services with Spring in JUnit?
- Hibernate, spring, JPS & isolation – custom isolation not supported
- HibernateException: Couldn’t obtain transaction-synchronized Session for current thread
- Error creating bean with name ‘entityManagerFactory
- How to configure transaction management for working with 2 different db in Spring?
- Mapping JPA or Hibernate projection query to DTO (Data Transfer Object)
- java.lang.IllegalStateException: No transactional EntityManager available
- FetchMode join makes no difference for ManyToMany relations in spring JPA repositories
- TransactionRequiredException Executing an update/delete query