public class AbstractCRUDAccessor<T extends AbstractIdentifiableObject> extends AbstractAccessor implements CRUDAccessor<T>
Modifier and Type | Field and Description |
---|---|
protected org.jongo.MongoCollection |
collection |
mongoClientSession
Constructor and Description |
---|
AbstractCRUDAccessor(MongoClientSession clientSession,
String collectionName,
Class<T> entityClass) |
Modifier and Type | Method and Description |
---|---|
T |
findByAttributes(Map<String,String> attributes)
Find an object by default attributes.
|
T |
findByAttributes(Map<String,String> attributes,
String attributesMapKey)
Find an object by attributes.
|
Spliterator<T> |
findManyByAttributes(Map<String,String> attributes)
Find objects by attributes.
|
Spliterator<T> |
findManyByAttributes(Map<String,String> attributes,
String attributesMapKey)
Find objects by attributes.
|
T |
get(org.bson.types.ObjectId id)
Get an object by id
|
T |
get(String id)
Get an object by id
|
Iterator<T> |
getAll() |
List<T> |
getRange(int skip,
int limit)
Get the range of objects specified by the skip/limit parameters browsing the collection
sorted by ID in the descending order
|
protected String |
queryByAttributes(Map<String,String> attributes) |
protected String |
queryByAttributes(Map<String,String> attributes,
String attributesMapKey) |
void |
remove(org.bson.types.ObjectId id) |
void |
save(Collection<? extends T> entities)
Save a list of entities.
|
T |
save(T entity)
Save an entity.
|
createOrUpdateCompoundIndex, createOrUpdateIndex, createOrUpdateTTLIndex, getJongoCollection, getMongoCollection
public AbstractCRUDAccessor(MongoClientSession clientSession, String collectionName, Class<T> entityClass)
public T get(org.bson.types.ObjectId id)
Accessor
get
in interface Accessor<T extends AbstractIdentifiableObject>
id
- the UID of the objectpublic T get(String id)
Accessor
get
in interface Accessor<T extends AbstractIdentifiableObject>
id
- the UID of the objectpublic T findByAttributes(Map<String,String> attributes)
Accessor
findByAttributes
in interface Accessor<T extends AbstractIdentifiableObject>
attributes
- the map of mandatory attributes of the object to be foundpublic Spliterator<T> findManyByAttributes(Map<String,String> attributes)
Accessor
findManyByAttributes
in interface Accessor<T extends AbstractIdentifiableObject>
attributes
- the map of mandatory attributes of the object to be foundIterator
for the objects foundpublic T findByAttributes(Map<String,String> attributes, String attributesMapKey)
Accessor
findByAttributes
in interface Accessor<T extends AbstractIdentifiableObject>
attributes
- the map of mandatory attributes of the object to be foundattributesMapKey
- the string representing the name (or "key") of the attribute mappublic Spliterator<T> findManyByAttributes(Map<String,String> attributes, String attributesMapKey)
Accessor
findManyByAttributes
in interface Accessor<T extends AbstractIdentifiableObject>
attributes
- the map of mandatory attributes of the object to be foundattributesMapKey
- the string representing the name (or "key") of the attribute mapIterator
for the objects foundprotected String queryByAttributes(Map<String,String> attributes, String attributesMapKey)
public Iterator<T> getAll()
getAll
in interface Accessor<T extends AbstractIdentifiableObject>
public void remove(org.bson.types.ObjectId id)
remove
in interface CRUDAccessor<T extends AbstractIdentifiableObject>
public T save(T entity)
CRUDAccessor
save
in interface CRUDAccessor<T extends AbstractIdentifiableObject>
entity
- the entity instance to be savedpublic void save(Collection<? extends T> entities)
CRUDAccessor
save
in interface CRUDAccessor<T extends AbstractIdentifiableObject>
entities
- the list of entities to be savedpublic List<T> getRange(int skip, int limit)
Accessor
getRange
in interface Accessor<T extends AbstractIdentifiableObject>
skip
- the start index (inclusive) of the rangelimit
- the size of the rangeList
containing the objects of the specified rangeCopyright © 2020. All rights reserved.