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 Detail

      • getStateHistory

        java.util.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

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

        java.util.List<CdoSnapshot> getStateHistory​(java.util.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

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

        Optional#EMPTY if object is not versioned
      • getLatest

        default java.util.List<CdoSnapshot> getLatest​(java.util.Collection<GlobalId> globalIds)
      • getSnapshots

        java.util.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

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

        void persist​(Commit commit)
      • setJsonConverter

        void setJsonConverter​(JsonConverter jsonConverter)
      • ensureSchema

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