我有一个由Hibernate加载的实体(通过EntityManager):
EntityManager
User u = em.load(User.class, id)
此类由Hibernate Envers审核。如何加载用户实体的先前版本?
也许然后(来自AuditReader文档)
AuditReader reader = AuditReaderFactory.get(entityManager); User user_rev1 = reader.find(User.class, user.getId(), 1); List<Number> revNumbers = reader.getRevisions(User.class, user_rev1); User user_previous = reader.find(User.class, user_rev1.getId(), revNumbers.get(revNumbers.size()-1));
(我对此很陌生,不确定我是否所有语法都正确,也许size()-1应该是size()-2吗?)