samedi 20 janvier 2018

Testing Hibernate Envers

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:

@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(bitComp)
    service.save(bitComp2)
    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.

Aucun commentaire:

Enregistrer un commentaire