I would like to write tests about revision. In the console I see the update call of Hibernate, BUT no insertions into AUD-Table.
Test-Method:
@DataJpaTest
class JPAHistoryTest {
@Test
public void test() {
def entity = // create Entity
def entity2 = // create same Entity
entity2.setPrice(entity2.getPrice() + 10)
entity2.setLastUpdate(entity2.lastUpdate.plusSeconds(10))
service.save(entity)
service.save(entity2)
repository.flush() // Hibernate updates changes
assert repository.findRevisions(entity.id).content.empty == false // FAIL!
}
}
My Entity looks like:
@Entity
@Audited
class Entity {
@Id @GeneratedValue Long id
@Column(nullable = false) BigDecimal price
}
Thank you very much.
testEntityManager.getEntityManager().getTransaction().commit();
is a magic line and it made Envers to trigger audit queries. – Marinara