O
- the Identifiable Object type that this service is handling.public abstract class AbstractService<O extends Identifiable> extends Object implements BaseService<O>
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
Modifier | Constructor and Description |
---|---|
protected |
AbstractService(BaseDao<O> mainDao) |
Modifier and Type | Method and Description |
---|---|
long |
countAll() |
Collection<O> |
create(Collection<O> entities)
Creates all the given entities in a persistent storage
|
O |
create(O entity)
Creates the given entity in the persistent storage.
|
O |
find(O entity)
Does a search for the entity in the persistent storage
|
O |
findOrCreate(O entity)
Does a search for the entity in the persistent storage, and if not found, creates it.
|
O |
findOrFail(O entity) |
Collection<O> |
load(Collection<Long> ids)
Loads objects with given ids.
|
O |
load(Long id)
Loads object with given ID.
|
Collection<O> |
loadAll()
Loads all the entities of specific type.
|
O |
loadOrFail(Long id)
Convenience for running
BaseService.load(Long) and checking if the result is null. |
void |
remove(Collection<O> entities)
Removes all the given entities from persistent storage.
|
void |
remove(Long id)
Removes the entity with given ID from the persistent storage.
|
void |
remove(O entity)
Removes the given entity from the persistent storage.
|
void |
removeAll()
Remove all entities from the persistent storage.
|
Collection<O> |
save(Collection<O> entities) |
O |
save(O entity) |
void |
update(Collection<O> entities)
Updates all entities in the given collection in the persistent storage.
|
void |
update(O entity)
Updates the given entity in the persistent storage.
|
@Transactional(readOnly=true) public O find(O entity)
BaseService
find
in interface BaseService<O extends Identifiable>
entity
- the entity to be searched for@Nonnull @Transactional(readOnly=true) public O findOrFail(O entity)
findOrFail
in interface BaseService<O extends Identifiable>
@Transactional public O findOrCreate(O entity)
BaseService
findOrCreate
in interface BaseService<O extends Identifiable>
entity
- the entity to look for, and create if not found.@Transactional public Collection<O> create(Collection<O> entities)
BaseService
create
in interface BaseService<O extends Identifiable>
entities
- the entities to be created.@Transactional @OverridingMethodsMustInvokeSuper public O create(O entity)
BaseService
create
in interface BaseService<O extends Identifiable>
entity
- the entity to be created.@Transactional public Collection<O> save(Collection<O> entities)
save
in interface BaseService<O extends Identifiable>
BaseDao.save(Collection)
@Transactional @OverridingMethodsMustInvokeSuper public O save(O entity)
save
in interface BaseService<O extends Identifiable>
BaseDao.save(Object)
@Transactional(readOnly=true) public Collection<O> load(Collection<Long> ids)
BaseService
load
in interface BaseService<O extends Identifiable>
ids
- the ids of objects to be loaded.@Transactional(readOnly=true) public O load(Long id)
BaseService
load
in interface BaseService<O extends Identifiable>
id
- the ID of entity to be loaded.@Nonnull @Transactional(readOnly=true) public O loadOrFail(Long id)
BaseService
BaseService.load(Long)
and checking if the result is null.loadOrFail
in interface BaseService<O extends Identifiable>
id
- the ID used to retrieve the entityBaseService.load(Long)
, never null@Transactional(readOnly=true) public Collection<O> loadAll()
BaseService
loadAll
in interface BaseService<O extends Identifiable>
@Transactional(readOnly=true) public long countAll()
countAll
in interface BaseService<O extends Identifiable>
@Transactional public void remove(Collection<O> entities)
BaseService
remove
in interface BaseService<O extends Identifiable>
entities
- the entities to be removed.@Transactional public void remove(Long id)
BaseService
remove
in interface BaseService<O extends Identifiable>
id
- the ID of entity to be removed.@Transactional @OverridingMethodsMustInvokeSuper public void remove(O entity)
BaseService
remove
in interface BaseService<O extends Identifiable>
entity
- the entity to be removed.@Transactional public void removeAll()
BaseService
removeAll
in interface BaseService<O extends Identifiable>
@Transactional public void update(Collection<O> entities)
BaseService
update
in interface BaseService<O extends Identifiable>
entities
- the entities to be updated.@Transactional @OverridingMethodsMustInvokeSuper public void update(O entity)
BaseService
update
in interface BaseService<O extends Identifiable>
entity
- the entity to be updated.Copyright © 2005–2023 Pavlidis lab, Michael Smith Laboratories and Department of Psychiatry, University of British Columbia. All rights reserved.