Package org.hibernate.envers.query
Class AuditQueryCreator
- java.lang.Object
-
- org.hibernate.envers.query.AuditQueryCreator
-
public class AuditQueryCreator extends Object
-
-
Constructor Summary
Constructors Constructor Description AuditQueryCreator(EnversService enversService, AuditReaderImplementor auditReaderImplementor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuditQuery
forEntitiesAtRevision(Class<?> c, Number revision)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision.AuditQuery
forEntitiesAtRevision(Class<?> c, String entityName, Number revision)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision and a given entityName.AuditQuery
forEntitiesAtRevision(Class<?> c, String entityName, Number revision, boolean includeDeletions)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision and a given entityName.AuditQuery
forEntitiesModifiedAtRevision(Class<?> c, Number revision)
Creates a query, which will return entities modified at the specified revision.AuditQuery
forEntitiesModifiedAtRevision(Class<?> c, String entityName, Number revision)
Creates a query, which will return entities modified at the specified revision.AuditQuery
forRevisionsOfEntity(Class<?> clazz, boolean selectDeletedEntities)
Creates a query that selects the revision entities associated with the specified entity.AuditQuery
forRevisionsOfEntity(Class<?> c, boolean selectEntitiesOnly, boolean selectDeletedEntities)
Creates a query, which selects the revisions, at which the given entity was modified.AuditQuery
forRevisionsOfEntity(Class<?> clazz, String entityName, boolean selectDeletedEntities)
Creates a query that selects the revision entities associated with the specified entity.AuditQuery
forRevisionsOfEntity(Class<?> c, String entityName, boolean selectEntitiesOnly, boolean selectDeletedEntities)
Creates a query, which selects the revisions, at which the given entity was modified and with a given entityName.AuditQuery
forRevisionsOfEntityWithChanges(Class<?> clazz, boolean selectDeletedEntities)
Creates a query that selects the revisions at which the given entity was modified.AuditQuery
forRevisionsOfEntityWithChanges(Class<?> clazz, String entityName, boolean selectDeletedEntities)
Creates a query that selects the revisions at which the given entity was modified.
-
-
-
Constructor Detail
-
AuditQueryCreator
public AuditQueryCreator(EnversService enversService, AuditReaderImplementor auditReaderImplementor)
-
-
Method Detail
-
forEntitiesAtRevision
public AuditQuery forEntitiesAtRevision(Class<?> c, Number revision)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision. Deleted entities are not included.- Parameters:
c
- Class of the entities for which to query.revision
- Revision number at which to execute the query.- Returns:
- A query for entities at a given revision, to which conditions can be added and which can then be executed. The result of the query will be a list of entities (beans), unless a projection is added.
-
forEntitiesAtRevision
public AuditQuery forEntitiesAtRevision(Class<?> c, String entityName, Number revision)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision and a given entityName. Deleted entities are not included.- Parameters:
c
- Class of the entities for which to query.entityName
- Name of the entity (if it can't be guessed basing on thec
).revision
- Revision number at which to execute the query.- Returns:
- A query for entities at a given revision, to which conditions can be added and which can then be executed. The result of the query will be a list of entities (beans), unless a projection is added.
-
forEntitiesAtRevision
public AuditQuery forEntitiesAtRevision(Class<?> c, String entityName, Number revision, boolean includeDeletions)
Creates a query, which will return entities satisfying some conditions (specified later), at a given revision and a given entityName. Deleted entities may be optionally included.- Parameters:
c
- Class of the entities for which to query.entityName
- Name of the entity (if it can't be guessed basing on thec
).revision
- Revision number at which to execute the query.includeDeletions
- Whether to include deleted entities in the search.- Returns:
- A query for entities at a given revision, to which conditions can be added and which can then be executed. The result of the query will be a list of entities (beans), unless a projection is added.
-
forEntitiesModifiedAtRevision
public AuditQuery forEntitiesModifiedAtRevision(Class<?> c, String entityName, Number revision)
Creates a query, which will return entities modified at the specified revision.In comparison, the
forEntitiesAtRevision(Class, String, Number)
query takes into all entities which were present at a given revision, even if they were not modified.- Parameters:
c
- Class of the entities for which to query.entityName
- Name of the entity (if it can't be guessed basing on thec
).revision
- Revision number at which to execute the query.- Returns:
- A query for entities changed at a given revision, to which conditions can be added and which can then be executed.
- See Also:
forEntitiesAtRevision(Class, String, Number)
-
forEntitiesModifiedAtRevision
public AuditQuery forEntitiesModifiedAtRevision(Class<?> c, Number revision)
Creates a query, which will return entities modified at the specified revision.In comparison, the
forEntitiesAtRevision(Class, String, Number)
query takes into all entities which were present at a given revision, even if they were not modified.- Parameters:
c
- Class of the entities for which to query.revision
- Revision number at which to execute the query.- Returns:
- A query for entities changed at a given revision, to which conditions can be added and which can then be executed.
- See Also:
forEntitiesAtRevision(Class, Number)
-
forRevisionsOfEntity
public AuditQuery forRevisionsOfEntity(Class<?> c, boolean selectEntitiesOnly, boolean selectDeletedEntities)
Creates a query, which selects the revisions, at which the given entity was modified. Unless an explicit projection is set, the result will be a list of three-element arrays, containing:- the entity instance
- revision entity, corresponding to the revision at which the entity was modified. If no custom
revision entity is used, this will be an instance of
DefaultRevisionEntity
- type of the revision (an enum instance of class
RevisionType
)
- Parameters:
c
- Class of the entities for which to query.selectEntitiesOnly
- If true, instead of a list of three-element arrays, a list of entities will be returned as a result of executing this query.selectDeletedEntities
- If true, also revisions where entities were deleted will be returned. The additional entities will have revision type "delete", and contain no data (all fields null), except for the id field.- Returns:
- A query for revisions at which instances of the given entity were modified, to which
conditions can be added (for example - a specific id of an entity of class
c
), and which can then be executed. The results of the query will be sorted in ascending order by the revision number, unless an order or projection is added.
-
forRevisionsOfEntity
public AuditQuery forRevisionsOfEntity(Class<?> c, String entityName, boolean selectEntitiesOnly, boolean selectDeletedEntities)
Creates a query, which selects the revisions, at which the given entity was modified and with a given entityName. Unless an explicit projection is set, the result will be a list of three-element arrays, containing:- the entity instance
- revision entity, corresponding to the revision at which the entity was modified. If no custom
revision entity is used, this will be an instance of
DefaultRevisionEntity
- type of the revision (an enum instance of class
RevisionType
)
- Parameters:
c
- Class of the entities for which to query.entityName
- Name of the entity (if it can't be guessed basing on thec
).selectEntitiesOnly
- If true, instead of a list of three-element arrays, a list of entities will be returned as a result of executing this query.selectDeletedEntities
- If true, also revisions where entities were deleted will be returned. The additional entities will have revision type "delete", and contain no data (all fields null), except for the id field.- Returns:
- A query for revisions at which instances of the given entity were modified, to which
conditions can be added (for example - a specific id of an entity of class
c
), and which can then be executed. The results of the query will be sorted in ascending order by the revision number, unless an order or projection is added.
-
forRevisionsOfEntity
@Incubating public AuditQuery forRevisionsOfEntity(Class<?> clazz, boolean selectDeletedEntities)
Creates a query that selects the revision entities associated with the specified entity. You may also specify whether the revision entities list should include those for deletions of the entity class.- Parameters:
clazz
- Class of the entities for which to query.selectDeletedEntities
- If true, the result will include revision entities where deletions occurred.- Returns:
- A query of revision entities based on the specified entity class. The results of the query will be stored in ascending order by the revision number unless an order is specified.
- Since:
- 5.3
-
forRevisionsOfEntity
@Incubating public AuditQuery forRevisionsOfEntity(Class<?> clazz, String entityName, boolean selectDeletedEntities)
Creates a query that selects the revision entities associated with the specified entity. You may also specify whether the revision entities list should include those for deletions of the entity class.- Parameters:
clazz
- Class of the entities for which to query.entityName
- Name of the entity (for cases where it cannot be guessed based on class clazz).selectDeletedEntities
- If true, the result will include revision entities where deletions occurred.- Returns:
- A query of revision entities based on the specified entity class. The results of the query will be stored in ascending order by the revision number unless an order is specified.
- Since:
- 5.3
-
forRevisionsOfEntityWithChanges
@Incubating public AuditQuery forRevisionsOfEntityWithChanges(Class<?> clazz, boolean selectDeletedEntities)
Creates a query that selects the revisions at which the given entity was modified. Unless a projection is set, the result will be a list of 4-element arrays, containing the following:- The entity instance
- Revision entity, corresponding to the revision where the entity was modified. If no custom
revision entity is used, this will be an instance of
DefaultRevisionEntity
. - The revision type, an enum of class
RevisionType
. - The names of the properties changed in this revision
- Parameters:
clazz
- Class of the entities for which to query.selectDeletedEntities
- If true, the result set will include revisions where entities were deleted.- Returns:
- the audit query
- Since:
- 5.3
-
forRevisionsOfEntityWithChanges
@Incubating public AuditQuery forRevisionsOfEntityWithChanges(Class<?> clazz, String entityName, boolean selectDeletedEntities)
Creates a query that selects the revisions at which the given entity was modified. Unless a projection is set, the result will be a list of 4-element arrays, containing the following:- The entity instance
- Revision entity, corresponding to the revision where the entity was modified. If no custom
revision entity is used, this will be an instance of
DefaultRevisionEntity
. - The revision type, an enum of class
RevisionType
. - The names of the properties changed in this revision
- Parameters:
clazz
- Class of the entities for which to query.entityName
- Name of the entity (if it can't be guessed basing on theclazz
).selectDeletedEntities
- If true, the result set will include revisions where entities were deleted.- Returns:
- the audit query
- Since:
- 5.3
-
-