2

I want latest revision number always to be known when saving/finding an entity. Can I have something like this, so latest revision number is always present in the entity?

@Entity
@Audited
class SomeEntity {
  @Id
  long id;

  String value;

  @RevisionNumber
  int revNum;
}

^^^ Note: this approach does NOT work. That's desirable behaviour.

  • for @RevisionNumber is documented: "The value of this property won't be set by Envers", whereas ([according to samples](https://docs.spring.io/spring-data/envers/docs/current/reference/html/#envers.usage)) (jpa)`@Version` should just contain the "revision number" of the (freshly merged) entity..please try(?) – xerx593 Aug 24 '22 at 14:37
  • Unfortunately, @Version annotation stand for optimistic locking stuff, it is not a revision number. – Oleksandr Cherniaiev Aug 24 '22 at 17:22
  • Ok. thank you for trying though!:) Then still : in the samples they show a way how to access "revisions" and meta data... I am confident, you can obtain it from/like there – xerx593 Aug 24 '22 at 17:24
  • 1
    Yeah, but I need to query objects one by one, while I need to have a list of objects along with their latest revision numbers.. – Oleksandr Cherniaiev Aug 24 '22 at 17:27

0 Answers0