Using EJB3 JPA with Spring/Hibernate and a Postgres database.
I have a loop in which I am creating multiple instances of an Entity and persisting these using the EntityManager, within one (large) transaction.
I want to be able to do a JPQL select query during this process to find other data to add to these Entities. However, when I call the getResultList
of the Query
instance, I get the dreaded "unsaved transient" exception related to the Entity that I'm in the middle of creating.
Is there any way to make the query/Hibernate ignore the unsaved transients and just do the select query? The query is not related to the Entity that I'm in the middle of creating, so I don't know why it is complaining.
The method which performs the Query is marked @Transactional(propagation=SUPPORTS, readOnly=true)
so the query should be executing within the same transaction/session as the creation of the Entities.