| Modifier and Type | Class and Description |
|---|---|
protected static interface |
GenericDao.QueryPathProvider<E,P>
Provides an interface for the subclasses to easily perform queries
without having to deal with a lot of boiler-plate code.
|
static class |
GenericDao.SqlComparator |
| Modifier | Constructor and Description |
|---|---|
protected |
GenericDao(Class<T> inEntityClass,
com.google.inject.Provider<javax.persistence.EntityManager> inManagerProvider)
Creates a generic DAO that handles the given type of entity.
|
| Modifier and Type | Method and Description |
|---|---|
T |
create(T entity)
Creates (persists) the given entity in the data store.
|
List<T> |
getAll()
Retrieves a list of all the entities of the given type in the data
store.
|
protected javax.persistence.EntityManager |
getEntityManager()
Returns an entity manager instance that can be used to interact with the
data source.
|
protected List<T> |
getListAsc(javax.persistence.metamodel.SingularAttribute<T,?> attribute) |
protected <Y> List<T> |
getListByAttribute(GenericDao.QueryPathProvider<T,Y> provider,
Y value)
Get a list of entities whose path value is the same as the given target
value.
|
protected <Y extends Number> |
getListByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
GenericDao.SqlComparator comparator,
Y value) |
protected <Y> List<T> |
getListByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value) |
protected <Y> T |
getUniqueByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute,
Y value)
Provides a convenient way for subclasses to implement simple queries that
compare an attribute of the entity to a target value.
|
T |
refresh(T entity)
Refreshes the given entity instance with latest information from the
data store.
|
T |
remove(T entity)
Removes the given entity from the data store.
|
T |
retrieve(PK uniqueId)
Retrieves the entity referred to by the unique identifier from the data
store.
|
T |
update(T entity)
Updates the data store using the given entity.
|
protected GenericDao(Class<T> inEntityClass, com.google.inject.Provider<javax.persistence.EntityManager> inManagerProvider)
inEntityClass - The type of entities to handle.inManagerProvider - Provides entity managers on demand.public T create(T entity)
Daopublic T retrieve(PK uniqueId)
Daopublic T update(T entity)
Daopublic T remove(T entity)
Daopublic T refresh(T entity)
Daopublic List<T> getAll()
Daoprotected List<T> getListAsc(javax.persistence.metamodel.SingularAttribute<T,?> attribute)
protected <Y> T getUniqueByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
Y - The type of the attribute and target value.attribute - The attribute of the entity to compare.value - The target value of the given attribute.protected <Y> List<T> getListByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute, Y value)
protected <Y extends Number> List<T> getListByAttribute(javax.persistence.metamodel.SingularAttribute<T,Y> attribute, GenericDao.SqlComparator comparator, Y value)
protected <Y> List<T> getListByAttribute(GenericDao.QueryPathProvider<T,Y> provider, Y value)
Y - The type of the target value and resulting attribute/column
value.provider - Provides the path from the entity to the target
attribute/column.value - The target value to compare with the resulting attribute
value.protected final javax.persistence.EntityManager getEntityManager()
Copyright © 2012–2016 Emory University. All rights reserved.