public class QueryBuilder
extends java.lang.Object
JqlQuery,
executed with Javers.findChanges(JqlQuery) and Javers.findSnapshots(JqlQuery)| Modifier and Type | Method and Description |
|---|---|
protected void |
addFilter(org.javers.repository.jql.Filter filter) |
QueryBuilder |
andProperty(java.lang.String propertyName)
Filters to snapshots with a given property on changed properties list.
|
JqlQuery |
build() |
static QueryBuilder |
byClass(java.lang.Class requiredClass)
Query for selecting changes (or snapshots) made on
any object (Entity or ValueObject) of given class.
|
static QueryBuilder |
byGlobalIdDTO(GlobalIdDTO globalId)
Deprecated.
|
static QueryBuilder |
byInstanceId(java.lang.Object localId,
java.lang.Class entityClass)
Query for selecting changes (or snapshots) made on a concrete Entity instance.
|
static QueryBuilder |
byValueObject(java.lang.Class ownerEntityClass,
java.lang.String path)
Query for selecting changes (or snapshots)
made on all ValueObjects at given path, owned by any instance of given Entity.
|
static QueryBuilder |
byValueObjectId(java.lang.Object ownerLocalId,
java.lang.Class ownerEntityClass,
java.lang.String path)
Query for selecting changes (or snapshots) made on a concrete ValueObject
(so a ValueObject owned by a concrete Entity instance).
|
QueryBuilder |
from(org.joda.time.LocalDate fromDate)
delegates to
from(LocalDateTime) with MIDNIGHT |
QueryBuilder |
from(org.joda.time.LocalDateTime from)
Limits Snapshots to be fetched from JaversRepository
to those created after (>=) given date.
|
protected java.util.List<org.javers.repository.jql.Filter> |
getFilters() |
protected QueryParams |
getQueryParams() |
QueryBuilder |
limit(int limit)
Limits number of Snapshots to be fetched from JaversRepository, default is 100.
|
QueryBuilder |
to(org.joda.time.LocalDate toDate)
delegates to
to(LocalDateTime) with MIDNIGHT |
QueryBuilder |
to(org.joda.time.LocalDateTime to)
Limits Snapshots to be fetched from JaversRepository
to those created before (<=) given date.
|
QueryBuilder |
withNewObjectChanges()
Alias to
withNewObjectChanges(boolean) with true |
QueryBuilder |
withNewObjectChanges(boolean newObjectChanges)
Affects changes query only.
|
public static QueryBuilder byClass(java.lang.Class requiredClass)
javers.findChanges( QueryBuilder.byClass(MyClass.class).build() );
public static QueryBuilder byInstanceId(java.lang.Object localId, java.lang.Class entityClass)
javers.findChanges( QueryBuilder.byInstanceId("bob", Person.class).build() );
public static QueryBuilder byValueObject(java.lang.Class ownerEntityClass, java.lang.String path)
byValueObjectId(Object, Class, String).public static QueryBuilder byValueObjectId(java.lang.Object ownerLocalId, java.lang.Class ownerEntityClass, java.lang.String path)
class Employee {
@Id String name;
Address primaryAddress;
}
...
javers.findChanges( QueryBuilder.byValueObjectId("bob", Employee.class, "primaryAddress").build() );
When ValueObject is stored in a List, use propertyName and list index separated by "/", for example:
class Employee {
@Id String name;
List<Address> addresses;
}
...
javers.findChanges( QueryBuilder.byValueObjectId("bob", Employee.class, "addresses/0").build() );
When ValueObject is stored as a Map value, use propertyName and map key separated by "/", for example:
class Employee {
@Id String name;
Map<String,Address> addressMap;
}
...
javers.findChanges( QueryBuilder.byValueObjectId("bob", Employee.class, "addressMap/HOME").build() );
@Deprecated public static QueryBuilder byGlobalIdDTO(GlobalIdDTO globalId)
public QueryBuilder andProperty(java.lang.String propertyName)
CdoSnapshot.getChanged()public QueryBuilder withNewObjectChanges(boolean newObjectChanges)
public QueryBuilder withNewObjectChanges()
withNewObjectChanges(boolean) with truepublic QueryBuilder limit(int limit)
public QueryBuilder from(org.joda.time.LocalDateTime from)
javers.commit(someObject); //Monday
javers.commit(someObject); //Wednesday
javers.commit(someObject); //Friday
Query for Snapshots from Wednesday gives you 2 results as expected:
Wednesday's and Friday's Snapshots.
to(LocalDateTime)public QueryBuilder from(org.joda.time.LocalDate fromDate)
from(LocalDateTime) with MIDNIGHTpublic QueryBuilder to(org.joda.time.LocalDateTime to)
public QueryBuilder to(org.joda.time.LocalDate toDate)
to(LocalDateTime) with MIDNIGHTprotected void addFilter(org.javers.repository.jql.Filter filter)
protected java.util.List<org.javers.repository.jql.Filter> getFilters()
protected QueryParams getQueryParams()
public JqlQuery build()