Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JTA 1.2's @Transactional not being applied to query methods [DATACMNS-732] #1196

Closed
spring-projects-issues opened this issue Jul 16, 2015 · 3 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Steve Wall opened DATACMNS-732 and commented

After upgrading to Spring Boot 1.2.5 an exception is being thrown when attempting to execute the below query.

Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
@Modifying
@Transactional
@Query(value = "insert into some_table (some_id) VALUES (?1)", nativeQuery = true)
public void insertSomeTable(long some_id);

It's as if the @Transactional annotation is being ignored. With Spring Boot 1.2.1 this works


Affects: 1.10.1 (Fowler SR1)

Reference URL: http://stackoverflow.com/questions/31440865/spring-boot-1-2-5-release-transaction

Issue Links:

  • DATACMNS-715 @Transactional customizations not applied correctly on redeclared methods

  • SPR-13246 Make AbstractFallbackTransactionAttributeSource.computeTransactionAttribute(…) protected

Backported to: 1.10.2 (Fowler SR2)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Drotbohm commented

Do you have any sample project to verify this?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Drotbohm commented

Are you using the EJB @Transactional by the way? I just played with a minimal sample and for some reason can add it to my codebase and it compiles but then at runtime the class not being detected and thus the transaction attribute lookup failing

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Drotbohm commented

Nevermind, I got it. The custom Spring Data JPA TransactionAttributeSource doesn't consider JTA 2.1's @Transactional which you apparently are using. Spring Boots starter for JPA pulls that one in, which makes it available for import in the code but then it's ultimately Spring Data JPA not considering it due to a special TransactionAttributeSource that's not aware of JTA 2.1's @Transactional yet.

Suggested workaround: use Spring's @Transactional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants