public final class DatabaseSupport extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DatabaseSupport.SqlComparator
Comparators for constructing where clauses that set a threshold on a
numerical value.
|
| Constructor and Description |
|---|
DatabaseSupport(javax.persistence.EntityManager entityManager)
Creates a database support instance that uses the provided entity manager
to construct queries.
|
DatabaseSupport(javax.inject.Provider<javax.persistence.EntityManager> entityManagerProvider)
Creates a database support instance that uses the provided entity manager
provider to construct queries.
|
| Modifier and Type | Method and Description |
|---|---|
<T> List<T> |
getAll(Class<T> entityCls)
Gets every instance of the specified entity in the database.
|
<T> List<T> |
getAll(Class<T> entityCls,
int firstResult,
int maxResults)
Gets every instance of the specified entity in the database.
|
<T extends HistoricalEntity<?>> |
getCurrent(Class<T> historicalEntityCls)
Gets every instance of the specified historical entity in the database.
|
<T extends HistoricalEntity<?>,Y> |
getCurrentListByAttribute(Class<T> historicalEntityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value)
Gets every instance of the specified historical entity in the database
that has the given value of the given attribute.
|
<T extends HistoricalEntity<?>,Y> |
getCurrentUniqueByAttribute(Class<T> historicalEntityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value)
Gets the instance of the specified historical entity in the database
that has the given value of the given attribute.
|
<T,Y> List<T> |
getListByAttribute(Class<T> entityCls,
QueryPathProvider<T,Y> provider,
Y value)
Executes a query for entities that match the given path value.
|
<T,Y extends Number> |
getListByAttribute(Class<T> entityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
DatabaseSupport.SqlComparator comparator,
Y value)
Executes a query for the entities that have the specified values of the
given numerical attribute.
|
<T,Y> List<T> |
getListByAttribute(Class<T> entityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value)
Executes a query for the entities that have the specified value of the
given attribute.
|
<T,Y> List<T> |
getListByAttributeIn(Class<T> entityCls,
QueryPathProvider<T,Y> provider,
List<Y> values)
Executes a query for entities that match the given path value.
|
<T,Y> List<T> |
getListByAttributeIn(Class<T> entityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
List<Y> values)
Executes a query for entities that have any of the given attribute
values.
|
<T,Y> T |
getUniqueByAttribute(Class<T> entityCls,
javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value)
Gets the entity that has the specified value of an attribute.
|
<T,Y> T |
getUniqueByAttribute(Class<T> entityCls,
String attributeName,
Y value)
Executes a query for the entity with the given attribute value.
|
public DatabaseSupport(javax.persistence.EntityManager entityManager)
entityManager - the entity manager to use. Cannot be
null.public DatabaseSupport(javax.inject.Provider<javax.persistence.EntityManager> entityManagerProvider)
entityManagerProvider - the entity manager provider to use. Cannot
be null.public <T> List<T> getAll(Class<T> entityCls)
T - the type of the entity.entityCls - the class of the specified entity. Cannot be
null.null.public <T> List<T> getAll(Class<T> entityCls, int firstResult, int maxResults)
T - the type of the entity.entityCls - the class of the specified entity. Cannot be
null.null.public <T extends HistoricalEntity<?>> List<T> getCurrent(Class<T> historicalEntityCls)
T - the type of the entity.historicalEntityCls - the class of the specified historical entity.
The entity must be a subtype of HistoricalEntity. Cannot be
null.null.public <T extends HistoricalEntity<?>,Y> T getCurrentUniqueByAttribute(Class<T> historicalEntityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
T - the type of the entity.The entity must be a subtype of
HistoricalEntity. Cannot be null.Y - the attribute's type.historicalEntityCls - the class of the specified historical entity.attribute - the attribute. Cannot be null.value - the value. Cannot be null.null.public <T extends HistoricalEntity<?>,Y> List<T> getCurrentListByAttribute(Class<T> historicalEntityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
T - the type of the entity.The entity must be a subtype of
HistoricalEntity. Cannot be null.Y - the attribute's type.historicalEntityCls - the class of the specified historical entity.attribute - the attribute. Cannot be null.value - the value. Cannot be null.null.public <T,Y> T getUniqueByAttribute(Class<T> entityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
T - the type of the entity.Y - the type of the attribute.entityCls - the entity class. Cannot be null.attribute - the attribute. Cannot be null.value - the value. If there is more than one matching instance, only
the first will be returned, and a warning will be logged.null if there is none.public <T,Y> T getUniqueByAttribute(Class<T> entityCls, String attributeName, Y value)
T - the type of the entity.Y - the type of the attribute.entityCls - the entity class. Cannot be null.attributeName - the name of the attribute. Cannot be
null.value - the value. If there is more than one matching instance, only
the first will be returned, and a warning will be logged.null if there is none.public <T,Y> List<T> getListByAttribute(Class<T> entityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
T - the type of the entity.Y - the type of the attribute.entityCls - the entity class. Cannot be null.attribute - the attribute. Cannot be null.value - the value.null.public <T,Y extends Number> List<T> getListByAttribute(Class<T> entityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, DatabaseSupport.SqlComparator comparator, Y value)
T - the type of the entity.Y - the type of the numerical attribute.entityCls - the entity class. Cannot be null.attribute - the attribute. Cannot be null.comparator - the comparator to use. Cannot be null.value - the value.null.public <T,Y> List<T> getListByAttributeIn(Class<T> entityCls, javax.persistence.metamodel.SingularAttribute<T,Y> attribute, List<Y> values)
T - the type of the entity.Y - the type of the attribute.entityCls - the entity class. Cannot be null.attribute - the attribute. Cannot be null.values - the values.null.public <T,Y> List<T> getListByAttribute(Class<T> entityCls, QueryPathProvider<T,Y> provider, Y value)
T - the type of the entity class.Y - the type of the target value and resulting attribute/column
value.entityCls - the entity class. Cannot be null.provider - provides the path from the entity to the target
attribute/column. Cannot be null.value - the target value to compare with the resulting attribute
value.null.public <T,Y> List<T> getListByAttributeIn(Class<T> entityCls, QueryPathProvider<T,Y> provider, List<Y> values)
T - the type of the entity class.Y - the type of the target value and resulting attribute/column
value.entityCls - the entity class. Cannot be null.provider - provides the path from the entity to the target
attribute/column. Cannot be null.values - the target value to compare with the resulting attribute
value.null.Copyright © 2016–2019 Emory University. All rights reserved.