Class PojoEntityManager
java.lang.Object
ch.tocco.nice2.persist.core.impl.hibernate.pojo.PojoEntityManager
- All Implemented Interfaces:
EntityManager
Hibernate adapter for the
EntityManager
interface-
Constructor Summary
ConstructorDescriptionPojoEntityManager
(TypeManager typeManager, ContextAdapter context, PersistenceService persistService, EntityModel entityModel) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add anEntityFacadeListener
.void
Add anEntityListener
.create()
Create a new entity (stateEntity.State.CONCEPTION
.createEntityList
(PrimaryKey... entities) createEntityList
(Entity... entities) Creates an EntityList of persistent entities of the same EntityModel.createQuery
(Collection<PrimaryKey> keys) Create a query that returns objects with known primary keys.Create aQuery
for all entities of that type.Deletes all entities of the currentEntityModel
on which the condition applies to in a single sql statement.get
(PrimaryKey key) Get an entity by a known primary key.Get an entity by unique_id field.Get the persistence context of this entity manager.getModel()
Get the entity type's model.void
Remove anEntityFacadeListener
.void
Remove anEntityListener
.@Nullable Entity
retrieve
(PrimaryKey key) Retrieve an entity by a known primary key.@Nullable Entity
Retrieve an entity by unique_id field.toString()
-
Constructor Details
-
PojoEntityManager
public PojoEntityManager(TypeManager typeManager, ContextAdapter context, PersistenceService persistService, EntityModel entityModel)
-
-
Method Details
-
get
Description copied from interface:EntityManager
Get an entity by a known primary key. If the entity with the specified key isn't present, in the database, this method throws aNotFoundException
. UseEntityManager.retrieve(PrimaryKey)
, if you prefer a `null` value, if the entity does not exist.- Specified by:
get
in interfaceEntityManager
- Parameters:
key
- The primary key.- Returns:
- An entity facade for the entity with the specified key
- Throws:
PersistException
- See Also:
-
retrieve
Description copied from interface:EntityManager
Retrieve an entity by a known primary key. UnlikeEntityManager.get(PrimaryKey)
, this method returnsnull
if the entity does not exist in the database or the current user has no access to the entity.- Specified by:
retrieve
in interfaceEntityManager
- Parameters:
key
- ThePrimaryKey
of the entity.- Returns:
- The entity or
null
, if the entity does not exist or is not accessible. - Throws:
PersistException
- If an error occurs.- See Also:
-
get
Description copied from interface:EntityManager
Get an entity by unique_id field. Throws if entity cannot be found.- Specified by:
get
in interfaceEntityManager
- Parameters:
uniqueId
- unique id value of entity.- Returns:
- An entity facade for the entity with the specified unique_id
- Throws:
PersistException
- See Also:
-
retrieve
Description copied from interface:EntityManager
Retrieve an entity by unique_id field.- Specified by:
retrieve
in interfaceEntityManager
- Parameters:
uniqueId
- unique id value of entity.- Returns:
- The entity or
null
, if the entity does not exist or is not accessible. - Throws:
PersistException
- See Also:
-
createQueryForAll
Description copied from interface:EntityManager
Create aQuery
for all entities of that type.- Specified by:
createQueryForAll
in interfaceEntityManager
- Returns:
- A query that queries all entities.
- Throws:
PersistException
-
createQuery
Description copied from interface:EntityManager
Create a query that returns objects with known primary keys. Note that the results will be returned in random order unless a sorting is applied. They will not be returned in the given keys order. UseEntityLists.orderedList(ch.tocco.nice2.persist.core.api.entity.EntityList, ch.tocco.nice2.model.entity.api.PrimaryKey[])
.- Specified by:
createQuery
in interfaceEntityManager
- Parameters:
keys
- A collection of known primary keys.- Returns:
- The executable query.
- Throws:
PersistException
-
createEntityList
Description copied from interface:EntityManager
Creates an EntityList of persistent entities of the same EntityModel.- Specified by:
createEntityList
in interfaceEntityManager
- Parameters:
entities
- Must be of same EntityModel, and persistent (not conception).- Returns:
- new EntityList of given persistent entities.
-
createEntityList
- Specified by:
createEntityList
in interfaceEntityManager
-
create
Description copied from interface:EntityManager
Create a new entity (stateEntity.State.CONCEPTION
. The entity won't have any primary key yet and will be written into the storage when the transaction is committed.- Specified by:
create
in interfaceEntityManager
- Returns:
- The newly created entity.
- Throws:
PersistException
-
delete
Description copied from interface:EntityManager
Deletes all entities of the currentEntityModel
on which the condition applies to in a single sql statement. Does not provide cascading delete.- Specified by:
delete
in interfaceEntityManager
-
getModel
Description copied from interface:EntityManager
Get the entity type's model.- Specified by:
getModel
in interfaceEntityManager
- Returns:
- The entity type's model.
-
getContext
Description copied from interface:EntityManager
Get the persistence context of this entity manager.- Specified by:
getContext
in interfaceEntityManager
- Returns:
- The persistence context of this entity manager.
-
addEntityListener
Description copied from interface:EntityManager
Add anEntityListener
.- Specified by:
addEntityListener
in interfaceEntityManager
- Parameters:
l
- TheEntityListener
to be added.
-
removeEntityListener
Description copied from interface:EntityManager
Remove anEntityListener
.- Specified by:
removeEntityListener
in interfaceEntityManager
- Parameters:
l
- TheEntityListener
to be removed.
-
getEntityListeners
-
addEntityFacadeListener
Description copied from interface:EntityManager
Add anEntityFacadeListener
.- Specified by:
addEntityFacadeListener
in interfaceEntityManager
- Parameters:
l
- TheEntityFacadeListener
to be added.
-
removeEntityFacadeListener
Description copied from interface:EntityManager
Remove anEntityFacadeListener
.- Specified by:
removeEntityFacadeListener
in interfaceEntityManager
- Parameters:
l
- TheEntityFacadeListener
to be removed.
-
getEntityFacadeListeners
-
toString
-