Insert and update with CriteriaBuilder JPA in the same transactional method thows error “Foreign Key not exist”
问题 I am trying to make an insertion and with the resulting entity update N records in the same transaction. The error "FK does not exist" occurs and observing the log trace of the query is executed in the reverse order to which the instructions were triggered. Service: @Transactional public Entity1 createEntity(Entity1 newEntity){ Entity1 inserted = dao.createEntity(newEntity); Integer numUpdated = dao.updateEntity2(newEntity) return inserted; } Dao: public Entity1 createEntity(Entity1 newEntity