Transaction marked as rollback only when initialising application when working with transaction manager [DATAJPA-1686]
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)
mirackle-spb commented
Possible solution: We can create new transaction within hasNamedQuery method for lookup purpose only
Jens Schauder commented
Please provide a reproducer, i.e. a small complete project demonstrating this issue preferable in the form of a failing test
Sławomir Luty commented
Jens Schauder Hi, I think I have such example. Should I attach it as zip(how) or publish repository somewhere ?
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
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.