Hibernate: NamedQuery is not finding previously created entities

16 Views Asked by At

I am working with Java 1.8, Hibernate 5.6.15.Final, Spring 5.3.27 and Spring.data Neumann-SR9

I have created several entities using Hibernate/JPA using getEntityManager().persist(entity), these entities are not visible for my named query executed directly after these method calls. The create and the query are executed in the same Transaction. When trying to retrieve the entities using the getEntityManager().findOneByKey(key) they are visible but not by executing the named query.

I have added a .setFlushMode(FlushModeType.AUTO) to the execution of the TypedQuery but it did't help. I have added a getEntityManager().flush() directly after the creation of the entities but it also didn't help. Is there anything I can do to make the created entities visible for the query? Can anyone help?

0

There are 0 best solutions below