ID - is the generic type if the primary key.E - is the generic type of the PersistenceEntity.public interface GenericDao<ID,E extends net.sf.mmm.util.entity.api.PersistenceEntity<ID>>
entity <E>.save(PersistenceEntity) on a new entity.find* methods such as findOne(Object). More specific queries will be added in
dedicated DAO interfaces.save(PersistenceEntity) to
merge an entity.delete(PersistenceEntity) or delete(Object).entity MyEntity you should create an
interface interface MyEntityDao that inherits from this GenericDao interface. Also you create an
implementation of that interface MyEntityDaoImpl that you derive from
AbstractGenericDao.| Modifier and Type | Method and Description |
|---|---|
void |
delete(E entity)
Deletes a given entity.
|
void |
delete(ID id)
Deletes the entity with the given id.
|
void |
delete(Iterable<? extends E> entities)
Deletes the given entities.
|
boolean |
exists(ID id)
Returns whether an entity with the given id exists.
|
E |
find(ID id)
Retrieves an entity by its id.
|
List<E> |
findAll(Iterable<ID> ids)
Returns all instances of the type with the given IDs.
|
E |
findOne(ID id)
Retrieves an entity by its id.
|
void |
forceIncrementModificationCounter(E entity)
Enforces to increment the
modificationCounter e.g. |
E |
save(E entity)
Saves a given entity.
|
void |
save(Iterable<? extends E> entities)
Saves all given entities.
|
E save(E entity)
entity - the entity to savevoid save(Iterable<? extends E> entities)
entities - the entities to saveE find(ID id) throws net.sf.mmm.util.exception.api.ObjectNotFoundUserException
id - must not be null.net.sf.mmm.util.exception.api.ObjectNotFoundUserException - if the requested entity does not exists (use findOne(Object) to
prevent).E findOne(ID id) throws IllegalArgumentException
id - must not be null.IllegalArgumentException - if id is nullboolean exists(ID id)
id - must not be null.void delete(ID id) throws IllegalArgumentException
id - must not be null.IllegalArgumentException - in case the given id is nullvoid delete(E entity)
entity - the entity to deletevoid delete(Iterable<? extends E> entities)
entities - the entities to deletevoid forceIncrementModificationCounter(E entity)
modificationCounter e.g. to enforce
that a parent object gets locked when its children are modified.Order and its contained
OrderPosition. By default the users can modify an Order and each of its OrderPositions in
parallel without getting a locking conflict. This can be desired. However, it can also be a demand that an
Order gets approved and the user doing that is responsible for the total price as the sum of the prices of
each OrderPosition. Now if another user is adding or changing an OrderPostion belonging to that
Order in parallel the Order will get approved but the approved total price will differ from what
the user has actually seen when he clicked on approve. To prevent this the use-case to modify an
OrderPosition can use this method to trigger a locking on the associated Order. The implication is
also that two users changing an OrderPosition associated with the same Order in parallel will get a
conflict.entity - that is getting checked.Copyright © 2014–2016 OASP-Team. All rights reserved.