|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.etaxonomy.cdm.api.service.ServiceBase<T,DAO>
public abstract class ServiceBase<T extends CdmBase,DAO extends ICdmEntityDao<T>>
| Field Summary | |
|---|---|
protected org.springframework.context.ApplicationContext |
appContext
|
protected DAO |
dao
|
| Constructor Summary | |
|---|---|
ServiceBase()
|
|
| Method Summary | |
|---|---|
void |
clear()
|
int |
count(Class<? extends T> clazz)
Returns a count of all entities of type |
UUID |
delete(T persistentObject)
Delete an existing persistent object |
boolean |
exists(UUID uuid)
Returns true if an entity of type |
T |
find(int id)
Return a persisted entity that matches the database identifier supplied as an argument, or null if the entity does not exist |
List<T> |
find(Set<UUID> uuidSet)
Return a list of persisted entities that match the unique identifier set supplied as an argument |
T |
find(UUID uuid)
Return a persisted entity that matches the unique identifier supplied as an argument, or null if the entity does not exist |
List<T> |
findById(Set<Integer> idSet)
Returns a List of persisted entities that match the database identifiers. |
org.hibernate.Session |
getSession()
|
List<Object[]> |
group(Class<? extends T> clazz,
Integer limit,
Integer start,
List<Grouping> groups,
List<String> propertyPaths)
Returns a sublist of objects matching the grouping projections supplied using the groups parameter It would be nice to be able to return a pager, but for the moment hibernate doesn't seem to support this (HHH-3238 - impossible to get the rowcount for a criteria that has projections) |
List<T> |
list(Class<? extends T> type,
Integer limit,
Integer start,
List<OrderHint> orderHints,
List<String> propertyPaths)
Returns a list of entities of type |
List<T> |
list(T example,
Set<String> includeProperties,
Integer limit,
Integer start,
List<OrderHint> orderHints,
List<String> propertyPaths)
Method that lists the objects matching the example provided. |
T |
load(UUID uuid)
Finds the cdm entity specified by the uuid parameter and
initializes all its *ToOne relations. |
T |
load(UUID uuid,
List<String> propertyPaths)
Finds the cdm entity specified by the uuid parameter and
recursively initializes all bean properties given in the
propertyPaths parameter. |
void |
lock(T t,
org.hibernate.LockMode lockMode)
Obtain the specified lock mode on the given object t |
T |
merge(T newInstance)
Copy the state of the given object onto the persistent object with the same identifier. |
Pager<T> |
page(Class<? extends T> type,
Integer pageSize,
Integer pageNumber,
List<OrderHint> orderHints,
List<String> propertyPaths)
Returns a paged list of entities of type |
UUID |
refresh(T persistentObject)
Re-read the state of the given instance from the underlying database. |
void |
refresh(T t,
org.hibernate.LockMode lockMode,
List<String> propertyPaths)
Refreshes a given object t using the specified lockmode All bean properties given in the propertyPaths parameter are recursively initialized. |
List<T> |
rows(String tableName,
int limit,
int start)
FIXME Candidate for harmonization is this method used, and if so, should it be exposed in the service layer? it seems a bit incongruous that we use an ORM to hide the fact that there is a database, then expose a method that talks about "rows" . |
Map<UUID,T> |
save(Collection<T> newInstances)
Save a collection containing new entities (persists the entities) |
UUID |
save(T newInstance)
Save a new entity (persists the entity) |
Map<UUID,T> |
saveOrUpdate(Collection<T> transientInstances)
Save new entities or update the persistent state of existing transient entities that have been persisted previously |
UUID |
saveOrUpdate(T transientObject)
Save a new entity or update the persistent state of an existing transient entity that has been persisted previously |
void |
setApplicationContext(org.springframework.context.ApplicationContext appContext)
|
protected abstract void |
setDao(DAO dao)
|
UUID |
update(T transientObject)
Update the persistent state of an existing transient entity that has been persisted previously |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.springframework.context.ApplicationContext appContext
protected DAO extends ICdmEntityDao<T> dao
| Constructor Detail |
|---|
public ServiceBase()
| Method Detail |
|---|
@Transactional(readOnly=true)
public void lock(T t,
org.hibernate.LockMode lockMode)
IService
lock in interface IService<T extends CdmBase>
@Transactional(readOnly=true)
public void refresh(T t,
org.hibernate.LockMode lockMode,
List<String> propertyPaths)
IServicepropertyPaths parameter are recursively initialized.
For detailed description and examples please refer to:
IBeanInitializer.initialize(Object, List)
NOTE: in the case of lockmodes that hit the database (e.g. LockMode.READ), you will need to re-initialize
child propertiesto avoid a HibernateLazyInitializationException (even if the properties of the child
were initialized prior to the refresh).
refresh in interface IService<T extends CdmBase>@Transactional(readOnly=false) public void clear()
clear in interface IService<T extends CdmBase>@Transactional(readOnly=true) public int count(Class<? extends T> clazz)
IService
count in interface IService<T extends CdmBase>clazz - the class of entities to be counted (can be null to count all entities of type @Transactional(readOnly=false) public UUID delete(T persistentObject)
IService
delete in interface IService<T extends CdmBase>persistentObject - the object to be deleted
@Transactional(readOnly=true) public boolean exists(UUID uuid)
IService
exists in interface IService<T extends CdmBase>uuid - the unique identifier of the entity required
@Transactional(readOnly=true) public List<T> find(Set<UUID> uuidSet)
IService
find in interface IService<T extends CdmBase>uuidSet - the set of unique identifiers of the entities required
@Transactional(readOnly=true) public List<T> findById(Set<Integer> idSet)
IServiceList of persisted entities that match the database identifiers.
Returns an empty list if no identifier matches.
findById in interface IService<T extends CdmBase>@Transactional(readOnly=true) public T find(UUID uuid)
IService
find in interface IService<T extends CdmBase>uuid - the unique identifier of the entity required
@Transactional(readOnly=true) public T find(int id)
IService
find in interface IService<T extends CdmBase>id - the database identifier of the entity required
@Transactional(readOnly=true) public org.hibernate.Session getSession()
getSession in interface IService<T extends CdmBase>
@Transactional(readOnly=true)
public List<Object[]> group(Class<? extends T> clazz,
Integer limit,
Integer start,
List<Grouping> groups,
List<String> propertyPaths)
IService
group in interface IService<T extends CdmBase>clazz - Restrict the query to objects of a certain class, or null for all objects of type T or subclasseslimit - the maximum number of entities returned (can be null to return
all entities)start - The (0-based) offset from the start of the recordset (can be null, equivalent of starting at the beginning of the recordset)groups - The grouping objects representing a projection, plus an optional ordering on that projected propertypropertyPaths - paths initialized on the returned objects - only applied to the objects returned from the first grouping
@Transactional(readOnly=true)
public List<T> list(Class<? extends T> type,
Integer limit,
Integer start,
List<OrderHint> orderHints,
List<String> propertyPaths)
IService
list in interface IService<T extends CdmBase>type - The type of entities to return (can be null to count all entities of type limit - The maximum number of objects returned (can be null for all matching objects)start - The offset from the start of the result set (0 - based, can be null - equivalent of starting at the beginning of the recordset)orderHints - Supports path like orderHints.propertyNames which
include *-to-one properties like createdBy.username or
authorTeam.persistentTitleCachepropertyPaths - properties to be initialized
@Transactional(readOnly=true) public T load(UUID uuid)
IServiceuuid parameter and
initializes all its *ToOne relations.
load in interface IService<T extends CdmBase>
@Transactional(readOnly=true)
public T load(UUID uuid,
List<String> propertyPaths)
IServiceuuid parameter and
recursively initializes all bean properties given in the
propertyPaths parameter.
For detailed description and examples please refer to:
IBeanInitializer.initialize(Object, List)
load in interface IService<T extends CdmBase>@Transactional(readOnly=false) public T merge(T newInstance)
IService
merge in interface IService<T extends CdmBase>newInstance - the entity to be merged
@Transactional(readOnly=true)
public Pager<T> page(Class<? extends T> type,
Integer pageSize,
Integer pageNumber,
List<OrderHint> orderHints,
List<String> propertyPaths)
IService
page in interface IService<T extends CdmBase>type - The type of entities to return (can be null to count all entities of type pageSize - The maximum number of objects returned (can be null for all matching objects)pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based,
can be null, equivalent of starting at the beginning of the recordset)orderHints - Supports path like orderHints.propertyNames which
include *-to-one properties like createdBy.username or
authorTeam.persistentTitleCachepropertyPaths - properties to be initialized
@Transactional(readOnly=true) public UUID refresh(T persistentObject)
IService
refresh in interface IService<T extends CdmBase>persistentObject - the object to be refreshed
@Transactional(readOnly=true)
public List<T> rows(String tableName,
int limit,
int start)
rows in interface IService<T extends CdmBase>@Transactional(readOnly=false) public Map<UUID,T> save(Collection<T> newInstances)
IService
save in interface IService<T extends CdmBase>newInstances - the new entities to be persisted
@Transactional(readOnly=false) public UUID save(T newInstance)
IService
save in interface IService<T extends CdmBase>newInstance - the new entity to be persisted
@Transactional(readOnly=false) public UUID saveOrUpdate(T transientObject)
IService
saveOrUpdate in interface IService<T extends CdmBase>transientObject - the entity to be persisted
@Transactional(readOnly=false) public Map<UUID,T> saveOrUpdate(Collection<T> transientInstances)
IService
saveOrUpdate in interface IService<T extends CdmBase>transientInstances - the entities to be persisted
public void setApplicationContext(org.springframework.context.ApplicationContext appContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwareprotected abstract void setDao(DAO dao)
@Transactional(readOnly=false) public UUID update(T transientObject)
IService
update in interface IService<T extends CdmBase>transientObject - the entity to be persisted
@Transactional(readOnly=true)
public List<T> list(T example,
Set<String> includeProperties,
Integer limit,
Integer start,
List<OrderHint> orderHints,
List<String> propertyPaths)
IService
list in interface IService<T extends CdmBase>limit - the maximum number of entities returned (can be null to return
all entities)start - The (0-based) offset from the start of the recordsetorderHints - Supports path like orderHints.propertyNames which
include *-to-one properties like createdBy.username orpropertyPaths - paths initialized on the returned objects - only applied to the objects returned from the first grouping
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||