public abstract class AbstractMongoCRUDService<T extends StorableObject> extends Object implements CRUDService<T>
Constructor and Description |
---|
AbstractMongoCRUDService() |
Modifier and Type | Method and Description |
---|---|
long |
count()
Returns the number of entities available.
|
void |
delete(String id)
Deletes the entity with the given id.
|
void |
deleteAll()
Deletes all entities managed by the repository.
|
boolean |
exists(String id)
Returns whether an entity with the given id exists.
|
Iterable<T> |
findAll()
Returns all instances of the type.
|
Iterable<T> |
findAll(int page,
int size)
Returns all instances of the given page.
|
T |
findOne(String id)
Retrieves an entity by its id.
|
protected abstract org.springframework.data.mongodb.repository.MongoRepository<T,String> |
getMongoStorage()
getMongoStorage.
|
<S extends T> |
update(S entity)
Updates an existing entity.
|
<S extends T> |
updateOrCreate(S entity)
Saves a given entity (creates it if it doesn't exist).
|
protected abstract org.springframework.data.mongodb.repository.MongoRepository<T,String> getMongoStorage()
getMongoStorage.
MongoRepository
object.public T findOne(String id) throws EntityNotFoundException
findOne
in interface CRUDService<T extends StorableObject>
id
- must not be null.EntityNotFoundException
- in case there is no entity with the given id
public <S extends T> S update(S entity) throws EntityNotFoundException
update
in interface CRUDService<T extends StorableObject>
S
- a S object.entity
- the entity to updateEntityNotFoundException
- in case there is no entity with the given id
public <S extends T> S updateOrCreate(S entity)
updateOrCreate
in interface CRUDService<T extends StorableObject>
S
- a S object.entity
- the entity to updatepublic boolean exists(String id)
exists
in interface CRUDService<T extends StorableObject>
id
- must not be null.public Iterable<T> findAll()
findAll
in interface CRUDService<T extends StorableObject>
public Iterable<T> findAll(int page, int size)
page
will return the first
page.
Returns all instances of the given page. Pages are zero indexed, thus providing 0 for page
will return the first
page.findAll
in interface CRUDService<T extends StorableObject>
page
- a int.size
- a int.public long count()
count
in interface CRUDService<T extends StorableObject>
public void delete(String id) throws EntityNotFoundException
delete
in interface CRUDService<T extends StorableObject>
id
- must not be null.EntityNotFoundException
- in case there is no entity with the given id
public void deleteAll()
deleteAll
in interface CRUDService<T extends StorableObject>
Copyright © 2011–2016 eXo Platform SAS. All rights reserved.