【发布时间】:2018-06-29 18:40:08
【问题描述】:
我想编写有关修订的测试。在控制台中,我看到了 Hibernate 的更新调用,但没有插入 AUD-Table。
测试方法:
@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!
}
}
我的实体看起来像:
@Entity
@Audited
class Entity {
@Id @GeneratedValue Long id
@Column(nullable = false) BigDecimal price
}
非常感谢。
【问题讨论】:
标签: hibernate testing junit hibernate-envers