Package ubic.gemma.persistence.service
Class AbstractService<O extends Identifiable>
java.lang.Object
ubic.gemma.persistence.service.AbstractService<O>
- Type Parameters:
O- the Identifiable Object type that this service is handling.
- All Implemented Interfaces:
BaseImmutableService<O>,BaseReadOnlyService<O>,BaseService<O>
- Direct Known Subclasses:
AbstractBulkExpressionDataVectorService,AbstractFilteringVoEnabledService,AbstractVoEnabledService,AnnotationAssociationServiceImpl,AuditTrailServiceImpl,BlatAssociationServiceImpl,ChromosomeServiceImpl,CoexpressionAnalysisServiceImpl,CompoundServiceImpl,DifferentialExpressionAnalysisServiceImpl,DifferentialExpressionResultServiceImpl,ExperimentalDesignServiceImpl,ExpressionExperimentSubSetServiceImpl,ExternalDatabaseServiceImpl,Gene2GOAssociationServiceImpl,GeneDiffExMetaAnalysisServiceImpl,PrincipalComponentAnalysisServiceImpl,ProtocolServiceImpl
public abstract class AbstractService<O extends Identifiable>
extends Object
implements BaseService<O>
Base for all services handling DAO access.
- Author:
- tesarst
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountAll()create(Collection<O> entities) protected Collection<O> ensureInSession(Collection<O> entities) Deprecated.avoid using this if possible and ensure that all operations are properly enclosed by a single Hibernate sessionprotected OensureInSession(O entity) Deprecated.avoid using this if possible and ensure that all operations are properly enclosed by a single Hibernate sessionfindOrCreate(O entity) findOrFail(O entity) Does a search for the entity in the persistent storage, raising aNullPointerExceptionif not found.load(Collection<Long> ids) loadAll()loadOrFail(Long id) Load an entity of fail with aNullPointerExceptionif it does not exist in the persistent storage.loadOrFail(Long id, Function<String, T> exceptionSupplier) Load an entity or fail with the supplied exception if it does not exist in the persistent storage.loadOrFail(Long id, Function<String, T> exceptionSupplier, String message) Load an entity or fail with the supplied exception and message.loadOrFail(Long id, Supplier<T> exceptionSupplier) Load an entity or fail with the supplied exception if it does not exist in the persistent storage.loadOrFail(Collection<Long> ids) Load multiple objects or fail with aNullPointerExceptionif any of the objects does not exist in the persistent storage.<T extends Exception>
Collection<O> loadOrFail(Collection<Long> ids, Function<String, T> exceptionSupplier) voidremove(Collection<O> entities) voidsave(Collection<O> entities) streamAll(boolean createNewSession) voidupdate(Collection<O> entities) void
-
Field Details
-
log
protected static final org.apache.commons.logging.Log log
-
-
Constructor Details
-
AbstractService
-
-
Method Details
-
getElementClass
- Specified by:
getElementClassin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
find
- Specified by:
findin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
findOrFail
Description copied from interface:BaseReadOnlyServiceDoes a search for the entity in the persistent storage, raising aNullPointerExceptionif not found.- Specified by:
findOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Parameters:
entity- the entity to be searched for- Returns:
- the version of entity retrieved from persistent storage
-
findOrCreate
- Specified by:
findOrCreatein interfaceBaseImmutableService<O extends Identifiable>- See Also:
-
create
- Specified by:
createin interfaceBaseImmutableService<O extends Identifiable>- See Also:
-
create
- Specified by:
createin interfaceBaseImmutableService<O extends Identifiable>- See Also:
-
save
- Specified by:
savein interfaceBaseService<O extends Identifiable>- See Also:
-
save
- Specified by:
savein interfaceBaseService<O extends Identifiable>- See Also:
-
load
- Specified by:
loadin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
loadOrFail
@Transactional(readOnly=true) public Collection<O> loadOrFail(Collection<Long> ids) throws NullPointerException Description copied from interface:BaseReadOnlyServiceLoad multiple objects or fail with aNullPointerExceptionif any of the objects does not exist in the persistent storage.- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Throws:
NullPointerException
-
loadOrFail
@Transactional(readOnly=true) public <T extends Exception> Collection<O> loadOrFail(Collection<Long> ids, Function<String, T> exceptionSupplier) throws T- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Throws:
T
-
load
- Specified by:
loadin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
loadOrFail
Description copied from interface:BaseReadOnlyServiceLoad an entity of fail with aNullPointerExceptionif it does not exist in the persistent storage.- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Parameters:
id- the ID used to retrieve the entity- Returns:
- the entity as per
BaseReadOnlyService.load(Long), never null - See Also:
-
loadOrFail
@Nonnull @Transactional(readOnly=true) public <T extends Exception> O loadOrFail(Long id, Supplier<T> exceptionSupplier) throws T Description copied from interface:BaseReadOnlyServiceLoad an entity or fail with the supplied exception if it does not exist in the persistent storage.- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Throws:
T- if the entity does not exist in the persistent storage- See Also:
-
loadOrFail
@Nonnull @Transactional(readOnly=true) public <T extends Exception> O loadOrFail(Long id, Function<String, T> exceptionSupplier) throws TDescription copied from interface:BaseReadOnlyServiceLoad an entity or fail with the supplied exception if it does not exist in the persistent storage.The message is generated automatically.
- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Throws:
T- if the entity does not exist in the persistent storage- See Also:
-
loadOrFail
@Nonnull @Transactional(readOnly=true) public <T extends Exception> O loadOrFail(Long id, Function<String, T> exceptionSupplier, String message) throws TDescription copied from interface:BaseReadOnlyServiceLoad an entity or fail with the supplied exception and message.- Specified by:
loadOrFailin interfaceBaseReadOnlyService<O extends Identifiable>- Throws:
T- if the entity does not exist in the persistent storage- See Also:
-
loadAll
- Specified by:
loadAllin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
countAll
@Transactional(readOnly=true) public long countAll()- Specified by:
countAllin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
streamAll
- Specified by:
streamAllin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
streamAll
- Specified by:
streamAllin interfaceBaseReadOnlyService<O extends Identifiable>- See Also:
-
remove
- Specified by:
removein interfaceBaseImmutableService<O extends Identifiable>- See Also:
-
remove
- Specified by:
removein interfaceBaseImmutableService<O extends Identifiable>- See Also:
-
update
- Specified by:
updatein interfaceBaseService<O extends Identifiable>- See Also:
-
update
- Specified by:
updatein interfaceBaseService<O extends Identifiable>- See Also:
-
ensureInSession
Deprecated.avoid using this if possible and ensure that all operations are properly enclosed by a single Hibernate sessionEnsure that a given entity is in the current session.If not found in the current session, it will be retrieved from the persistent storage.
-
ensureInSession
Deprecated.avoid using this if possible and ensure that all operations are properly enclosed by a single Hibernate sessionEnsure that a collection of entities are in the current session.Implementation note: if all entities are already in the session - or are transient, this call is very fast and does not involve any database interaction, otherwise the persistent entities are fetched in bulk.
- See Also:
-