|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.silverpeas.persistence.repository.jpa.SilverpeasJpaEntityManager<ENTITY,ENTITY_IDENTIFIER_TYPE>
ENTITY
- specify the class name of the entity which is handled by the repository
manager.ENTITY_IDENTIFIER_TYPE
- the identifier class name used by ENTITY
for its
primary key definition.public class SilverpeasJpaEntityManager<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
A Silverpeas dedicated entity manager that wraps the JPA EntityManager
and that provides convenient methods to perform the CRUD operations on entities.
NamedParameters
).
Constructor Summary | |
---|---|
SilverpeasJpaEntityManager()
|
Method Summary | ||
---|---|---|
protected ENTITY_IDENTIFIER_TYPE |
convertToEntityIdentifier(String idAsString)
Converts the given String id into the right entity identifier. |
|
protected Collection<ENTITY_IDENTIFIER_TYPE> |
convertToEntityIdentifiers(Collection<String> idsAsString)
Converts the given String ids into the right entity identifiers. |
|
protected Collection<ENTITY_IDENTIFIER_TYPE> |
convertToEntityIdentifiers(String... idsAsString)
Converts the given String ids into the right entity identifiers. |
|
void |
delete(ENTITY... entity)
Deletes entities. |
|
void |
delete(List<ENTITY> entities)
Deletes entities. |
|
long |
deleteById(Collection<String> ids)
Deletes entities by their ids. |
|
long |
deleteById(String... ids)
Deletes entities by their ids. |
|
protected long |
deleteFromJpqlQuery(String jpqlQuery,
NamedParameters parameters)
Deletes entities from a jpql query. |
|
protected long |
deleteFromNamedQuery(String namedQuery,
NamedParameters parameters)
Deletes entities from a named query. |
|
List<ENTITY> |
findByCriteria(QueryCriteria criteria)
Lists entities from the specified criteria. |
|
List<ENTITY> |
findByNamedQuery(String namedQuery,
NamedParameters parameters)
Finds the entities by the specified named query (a JPQL instruction) and with the specified parameters. |
|
ENTITY |
findOneByNamedQuery(String namedQuery,
NamedParameters parameters)
Finds the first or the single entity matching the specified named query (a JPQL instruction) and with the specified parameters. |
|
void |
flush()
Synchronizes the persistence context to the underlying data source. |
|
List<ENTITY> |
getAll()
Gets all persisted entities. |
|
List<ENTITY> |
getById(Collection<String> ids)
Gets persisted entities by their ids. |
|
List<ENTITY> |
getById(String... ids)
Gets persisted entities by their ids. |
|
ENTITY |
getById(String id)
Gets a persisted entity by its id. |
|
protected Class<ENTITY> |
getEntityClass()
Gets the entity class managed by the repository. |
|
protected Class<ENTITY_IDENTIFIER_TYPE> |
getEntityIdentifierClass()
Gets the identifier class of the entity managed by the repository. |
|
protected ENTITY |
getFromJpqlString(String jpqlQuery,
NamedParameters parameters)
Gets an entity from a jpql query string. |
|
protected
|
getFromJpqlString(String jpqlQuery,
NamedParameters parameters,
Class<AN_ENTITY> returnEntityType)
Gets an entity from a jpql query string. |
|
protected ENTITY |
getFromNamedQuery(String namedQuery,
NamedParameters parameters)
Gets an entity from a named query. |
|
protected
|
getFromNamedQuery(String namedQuery,
NamedParameters parameters,
Class<AN_ENTITY> returnEntityType)
Gets an entity from a named query. |
|
protected int |
getMaximumItemsInClause()
Gets the maximum items in a in clause. |
|
protected List<ENTITY> |
listFromJpqlString(String jpqlQuery,
NamedParameters parameters)
Lists entities from a jpql query string. |
|
protected
|
listFromJpqlString(String jpqlQuery,
NamedParameters parameters,
Class<AN_ENTITY> returnEntityType)
Lists entities from a JPQL query string. |
|
protected List<ENTITY> |
listFromNamedQuery(String namedQuery,
NamedParameters parameters)
Lists entities from a named query. |
|
protected
|
listFromNamedQuery(String namedQuery,
NamedParameters parameters,
Class<AN_ENTITY> returnEntityType)
Lists entities from a named query. |
|
NamedParameters |
newNamedParameters()
Gets a new query parameter container. |
|
List<ENTITY> |
save(OperationContext context,
ENTITY... entities)
Persists entities : create (if id is null or empty) or update. |
|
ENTITY |
save(OperationContext context,
ENTITY entity)
Persists entity : create (if id is null or empty) or update. |
|
List<ENTITY> |
save(OperationContext context,
List<ENTITY> entities)
Persists entities : create (if id is null or empty) or update. |
|
protected void |
setMaximumItemsInClause(int maximumItemsInClause)
Sets the maximum items in a in clause. |
|
protected
|
split(Collection<E> collection)
Collection spliter, useful for in clauses. |
|
protected long |
updateFromJpqlQuery(String jpqlQuery,
NamedParameters parameters)
Updates entities from a jpql query. |
|
protected long |
updateFromNamedQuery(String namedQuery,
NamedParameters parameters)
Updates entities from a named query. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SilverpeasJpaEntityManager()
Method Detail |
---|
protected Class<ENTITY> getEntityClass()
protected Class<ENTITY_IDENTIFIER_TYPE> getEntityIdentifierClass()
protected ENTITY_IDENTIFIER_TYPE convertToEntityIdentifier(String idAsString)
idAsString
-
protected Collection<ENTITY_IDENTIFIER_TYPE> convertToEntityIdentifiers(String... idsAsString)
idsAsString
-
protected Collection<ENTITY_IDENTIFIER_TYPE> convertToEntityIdentifiers(Collection<String> idsAsString)
idsAsString
-
public void flush()
public List<ENTITY> findByNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- the named query. It is an identifier to a JPQL instruction.parameters
- the parameters to apply on the query.
public ENTITY findOneByNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- the named query. It is an identifier to a JPQL instruction.parameters
- the parameters to apply on the query.
public List<ENTITY> getAll()
EntityRepository
getAll
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public ENTITY getById(String id)
EntityRepository
getById
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public List<ENTITY> getById(String... ids)
EntityRepository
getById
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public List<ENTITY> getById(Collection<String> ids)
EntityRepository
getById
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public ENTITY save(OperationContext context, ENTITY entity)
EntityRepository
save
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
context
- the context of the save operation (containing the user saver for example).entity
- the entity to save.
public List<ENTITY> save(OperationContext context, ENTITY... entities)
EntityRepository
save
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
context
- the context of the save operation (containing the user saver for example).entities
- the entities to save.
public List<ENTITY> save(OperationContext context, List<ENTITY> entities)
EntityRepository
save
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
context
- the context of the save operation (containing the user saver for example).entities
- the entities to save.
public void delete(ENTITY... entity)
EntityRepository
delete
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public void delete(List<ENTITY> entities)
EntityRepository
delete
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public long deleteById(String... ids)
EntityRepository
deleteById
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public long deleteById(Collection<String> ids)
EntityRepository
deleteById
in interface EntityRepository<ENTITY extends Entity<ENTITY,ENTITY_IDENTIFIER_TYPE>,ENTITY_IDENTIFIER_TYPE extends EntityIdentifier>
public NamedParameters newNamedParameters()
protected ENTITY getFromJpqlString(String jpqlQuery, NamedParameters parameters)
jpqlQuery
- the JPQL query in string.parameters
- the parameters to apply to the query.
IllegalArgumentException
- if it exists more than one entity from the query result.protected <AN_ENTITY> AN_ENTITY getFromJpqlString(String jpqlQuery, NamedParameters parameters, Class<AN_ENTITY> returnEntityType)
AN_ENTITY
- the type of the returned entities.jpqlQuery
- the JPQL query in string.parameters
- the parameters to apply to the query.returnEntityType
- the class of the returned entities.
IllegalArgumentException
- if it exists more than one entity from the query result.protected List<ENTITY> listFromJpqlString(String jpqlQuery, NamedParameters parameters)
jpqlQuery
- the JPQL query in string.parameters
- the parameters to apply to the query.
protected <AN_ENTITY> List<AN_ENTITY> listFromJpqlString(String jpqlQuery, NamedParameters parameters, Class<AN_ENTITY> returnEntityType)
AN_ENTITY
- the type of the returned entities.jpqlQuery
- the JPQL query in string.parameters
- the parameters to apply to the query.returnEntityType
- the class of the returned entities.
public List<ENTITY> findByCriteria(QueryCriteria criteria)
criteria
- the criteria constraining the query and for which the entities to list have to
satisfy.
PaginationList
instance.protected long updateFromJpqlQuery(String jpqlQuery, NamedParameters parameters)
jpqlQuery
- the query stringparameters
- the parameters to apply to the query.
protected long deleteFromJpqlQuery(String jpqlQuery, NamedParameters parameters)
jpqlQuery
- the query string.parameters
- the parameters to apply to the query.
protected ENTITY getFromNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- the name of the query.parameters
- the parameters to apply to the query.
IllegalArgumentException
- if it exists more than one entity from the query result.protected <AN_ENTITY> AN_ENTITY getFromNamedQuery(String namedQuery, NamedParameters parameters, Class<AN_ENTITY> returnEntityType)
AN_ENTITY
- the type of the returned entities.namedQuery
- the name of the query.parameters
- the parameters to apply to the query.returnEntityType
- the class of the returned entities.
IllegalArgumentException
- if it exists more than one entity from the query result.protected List<ENTITY> listFromNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- the n ame of the query.parameters
- the parameters to apply to the query.
protected <AN_ENTITY> List<AN_ENTITY> listFromNamedQuery(String namedQuery, NamedParameters parameters, Class<AN_ENTITY> returnEntityType)
AN_ENTITY
- namedQuery
- parameters
- returnEntityType
-
protected long updateFromNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- parameters
-
protected long deleteFromNamedQuery(String namedQuery, NamedParameters parameters)
namedQuery
- parameters
-
protected <E> Collection<Collection<E>> split(Collection<E> collection)
E
- collection
-
protected int getMaximumItemsInClause()
protected void setMaximumItemsInClause(int maximumItemsInClause)
maximumItemsInClause
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |