Interface JaversRepository

All Known Implementing Classes:
InMemoryRepository, JaversExtendedRepository

public interface JaversRepository
JaversRepository is responsible for persisting Commits calculated by Javers core.

It should persist CommitMetadata and Snapshots, Changes should not be persisted as they are recalculated by Javers core as diff between relevant snapshots.

Hints for JaversRepository implementation

  • After persisting in database, Commit is considered immutable so it can not be updated.
  • Persisting Commit in any kind of database is easy. JaVers provides flexible JSON serialization/deserialization engine, designed as abstraction layer between Java types and specific database types.
  • Essentially, object-oriented data are persisted as JSON.
  • Repository impl should leverage JsonConverter.
  • Method Details

    • getStateHistory

      List<CdoSnapshot> getStateHistory(GlobalId globalId, QueryParams queryParams)
      Snapshots (historical states) of given object in reverse chronological order
      Parameters:
      queryParams - parameters constraining returned list (size limit, util from/to)
      Returns:
      empty List if object is not versioned
    • getValueObjectStateHistory

      List<CdoSnapshot> getValueObjectStateHistory(EntityType ownerEntity, String path, QueryParams queryParams)
      Snapshots of all ValueObjects owned by given ownerEntity at given path
    • getStateHistory

      List<CdoSnapshot> getStateHistory(Set<ManagedType> givenClasses, QueryParams queryParams)
      All snapshots of objects within given managed classes, in reverse chronological order
      Parameters:
      queryParams - parameters constraining returned list (size limit, util from/to)
      Returns:
      empty List if no snapshots found
    • getLatest

      Optional<CdoSnapshot> getLatest(GlobalId globalId)
      Latest snapshot of a given object.

      Optional#EMPTY if object is not versioned
    • getLatest

      default List<CdoSnapshot> getLatest(Collection<GlobalId> globalIds)
    • getSnapshots

      List<CdoSnapshot> getSnapshots(QueryParams queryParams)
      Snapshots of all objects in reverse chronological order
      Parameters:
      queryParams - parameters constraining returned list (size limit, util from/to)
    • getSnapshots

      List<CdoSnapshot> getSnapshots(Collection<SnapshotIdentifier> snapshotIdentifiers)
      Snapshots with specified globalId and version
    • persist

      void persist(Commit commit)
    • getHeadId

      CommitId getHeadId()
    • setJsonConverter

      void setJsonConverter(JsonConverter jsonConverter)
    • ensureSchema

      void ensureSchema()
      Called at the end of JaVers bootstrap, good place to put database schema update