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

Transaction marked as rollback only when initialising application when working with transaction manager [DATAJPA-1686] #1983

Open
spring-projects-issues opened this issue Feb 24, 2020 · 6 comments
Assignees
Labels
in: core Issues in core support type: bug A general bug

Comments

@spring-projects-issues
Copy link

mirackle-spb opened DATAJPA-1686 and commented

Looks like DATAJPA-617  is not completely resolved. My app doing some data work while context initialisation is in progress. Inserting default data to database. When it initialising it depends on JpaReposiotory. When spring tries to initialise Repository spring-data-jpa make check for existence of named queries.

Within NamedQuery.javaa when lookupEm.createNamedQuery is called. Later Hibernate in AbstractSharedSessionContract query is not found and exceprion is fired. Hibernate ExceptionConverterImpl fire markForRollbackOnly.

Spring-data catches this exception but it is not matter at this point. Transaction is already marked.

Problem reproduced in 100% of cases when JTA transaction manager is in use


Affects: 2.2.4 (Moore SR4)

@spring-projects-issues
Copy link
Author

mirackle-spb commented

Possible solution: We can create new transaction within hasNamedQuery method for lookup purpose only

@spring-projects-issues
Copy link
Author

Jens Schauder commented

Please provide a reproducer, i.e. a small complete project demonstrating this issue preferable in the form of a failing test

@spring-projects-issues
Copy link
Author

Sławomir Luty commented

Jens Schauder Hi, I think I have such example. Should I attach it as zip(how) or publish repository somewhere ?

@spring-projects-issues
Copy link
Author

Jens Schauder commented

slawomir.luty Both is possible, but I prefer a Github repository

@spring-projects-issues
Copy link
Author

Sławomir Luty commented

Take a look at this one, please:

https://github.com/slo/jpa-example/tree/error_reproduced

I prepaired it to use external jboss eap 7.3, but I think it is possible to also run with wildfly (maybe even embedded).
If any help is needed regarding this repository, don't hesitate to ask.
Sorry for the mess, but I only wanted to reprodce this error - if any simplification is needed - I can do it

@dbarciela
Copy link

dbarciela commented Jan 20, 2022

I have a similar problem. My spring configuration is annotated with "@EnableJpaRepositories( bootstrapMode = BootstrapMode.LAZY...". When I use a repository for the first time inside a transaction and it includes query methods like "findByMycolumn", my transaction will be marked as rollbackonly for the same reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants