Class EntityManagerImpl
- All Implemented Interfaces:
- AbstractEntityManager,- EntityManager,- ConfigurationHolder,- Wrapper,- AutoCloseable
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Clear the persistence context, causing all managed entities to become detached.voidclose()Close an application-managed EntityManager.booleanCheck if the instance belongs to the current persistence context.createDescriptor(Class<?> cls) Creates aDescriptorfor instances of the specified entity class.createNamedQuery(String name) Create an instance of Query for executing a named query (in native SPARQL).<T> TypedQueryImpl<T>createNamedQuery(String name, Class<T> resultClass) Create an instance of TypedQuery for executing a SPARQL named query.createNativeQuery(String sparqlString) Create an instance of Query for executing a native SPARQL(-DL) query in SPARQL syntax.<T> TypedQueryImpl<T>createNativeQuery(String sparqlString, Class<T> resultClass) Create an instance of Query for executing a native SPARQL(-DL) query returning only specific object type.createNativeQuery(String sparqlString, String resultSetMapping) Create an instance of Query for executing a native SPARQL query.<T> TypedQuery<T>createQuery(CriteriaQuery<T> criteriaQuery) Create an instance of TypedQuery for executing a criteria query.createQuery(String qlString) Create an instance of Query for executing a Java Persistence query language statement.<T> TypedQueryImpl<T>createQuery(String query, Class<T> resultClass) Creates an instance of query for executing Java persistence query language statement.voidRemove the given entity from the persistence context, causing a managed entity to become detached.protected voidfinalize()<T> TFind by identifier.<T> Tfind(Class<T> cls, Object identifier, Descriptor descriptor) Find by identifier.voidflush()Synchronize the persistence context to the underlying database.Gets provider configuration.Returns a list of repository contexts available to this entity manager.Return a criteriaFactory for making CriteriaQuery.Return the UnitOfWork that holds the current persistence context.Return the underlying provider object for the EntityManager, if available.Return the entity manager factory for the entity manager.Return an instance of Metamodel interface for access to the metamodel of the persistence unit.Get the properties and hints and associated values that are in effect for the entity manager.<T> TgetReference(Class<T> entityClass, Object identifier) Get an instance, whose state may be lazily fetched.<T> TgetReference(Class<T> entityClass, Object identifier, Descriptor descriptor) Get an instance, whose state may be lazily fetched.Return the resource-level transaction object.booleanisConsistent(URI context) Checks consistency of the specified context.<T> booleanisInferred(T entity, FieldSpecification<? super T, ?> attribute, Object value) Checks whether the specified attribute value of the specified entity is inferred in the underlying repository.booleanbooleanbooleanisOpen()Determine whether the EntityManager is open.<T> Tmerge(T entity) Merge the state of the given entity into the current persistence context.<T> Tmerge(T entity, Descriptor descriptor) Merge the state of the given entity into the current persistence context and into the repository specified bydescriptor.voidMake an instance managed and persistent.voidpersist(Object entity, Descriptor descriptor) Make an instance managed and persistent.voidRefresh the state of the instance from the data source, overwriting changes made to the entity, if any.voidRemove the entity instance.voidCalled from EntityTransaction in case of a rollback.voidsetProperty(String propertyName, Object value) Set an entity manager property or hint.voidLet the managing server session know that a transaction has finished successfully.voidLet the managing server session know that a transaction has been started.<T> TReturn an object of the specified type to allow access to the provider-specific API.
- 
Method Details- 
persistDescription copied from interface:EntityManagerMake an instance managed and persistent.The entity is persisted into the default context. - Specified by:
- persistin interface- EntityManager
- Parameters:
- entity- entity instance
- See Also:
 
- 
persistDescription copied from interface:EntityManagerMake an instance managed and persistent.The descriptorrepresents repository and context into which the entity and its fields should be persisted.- Specified by:
- persistin interface- EntityManager
- Parameters:
- entity- entity instance
- descriptor- Entity descriptor
 
- 
mergepublic <T> T merge(T entity) Description copied from interface:EntityManagerMerge the state of the given entity into the current persistence context.The entity is merged into the default repository context. - Specified by:
- mergein interface- EntityManager
- Parameters:
- entity- The entity to merge
- Returns:
- the instance that the state was merged to
 
- 
mergeDescription copied from interface:EntityManagerMerge the state of the given entity into the current persistence context and into the repository specified bydescriptor.- Specified by:
- mergein interface- EntityManager
- Parameters:
- entity- The entity to merge
- descriptor- Entity descriptor
- Returns:
- the instance that the state was merged to
 
- 
removeDescription copied from interface:EntityManagerRemove the entity instance.- Specified by:
- removein interface- EntityManager
- Parameters:
- entity- The instance to remove
 
- 
findDescription copied from interface:EntityManagerFind by identifier.Search for an entity of the specified class and identifier. If the entity instance is contained in the persistence context, it is returned from there. - Specified by:
- findin interface- EntityManager
- Parameters:
- cls- Entity class
- identifier- Entity identifier
- Returns:
- the found entity instance or nullif the entity does not exist in the given ontology context
 
- 
findDescription copied from interface:EntityManagerFind by identifier.Search for an entity of the specified class and identifier. If the entity instance is contained in the persistence context, it is returned from there. The descriptorparameter represents repository and context in which the entity should be looked for.- Specified by:
- findin interface- EntityManager
- Parameters:
- cls- Entity class
- identifier- Entity identifier
- descriptor- Entity descriptor
- Returns:
- the found entity instance or nullif the entity does not exist in the given ontology context
- See Also:
 
- 
getReferenceDescription copied from interface:EntityManagerGet an instance, whose state may be lazily fetched.If the requested instance does not exist in the database, the EntityNotFoundExceptionis thrown when the instance state is first accessed. (The persistence provider runtime is permitted to throw theEntityNotFoundExceptionwhen getReference is called.)The application should not expect that the instance state will be available upon detachment, unless it was accessed by the application while the entity manager was open. - Specified by:
- getReferencein interface- EntityManager
- Parameters:
- entityClass- entity class
- identifier- identifier of the instance
- Returns:
- the found entity instance
 
- 
getReferenceDescription copied from interface:EntityManagerGet an instance, whose state may be lazily fetched.If the requested instance does not exist in the database, the EntityNotFoundExceptionis thrown when the instance state is first accessed. (The persistence provider runtime is permitted to throw theEntityNotFoundExceptionwhen getReference is called.)The application should not expect that the instance state will be available upon detachment, unless it was accessed by the application while the entity manager was open. The descriptorparameter represents configuration of the entity loading (e.g., repository context).- Specified by:
- getReferencein interface- EntityManager
- Parameters:
- entityClass- entity class
- identifier- identifier of the instance
- descriptor- Entity descriptor
- Returns:
- the found entity instance
 
- 
flushpublic void flush()Description copied from interface:EntityManagerSynchronize the persistence context to the underlying database.- Specified by:
- flushin interface- EntityManager
 
- 
refreshDescription copied from interface:EntityManagerRefresh the state of the instance from the data source, overwriting changes made to the entity, if any.- Specified by:
- refreshin interface- EntityManager
- Parameters:
- entity- The entity instance to refresh
 
- 
clearpublic void clear()Description copied from interface:EntityManagerClear the persistence context, causing all managed entities to become detached. Changes made to entities that have not been flushed to the database will not be persisted.- Specified by:
- clearin interface- EntityManager
 
- 
detachDescription copied from interface:EntityManagerRemove the given entity from the persistence context, causing a managed entity to become detached. Unflushed changes made to the entity if any (including removal of the entity), will not be synchronized to the database. Entities which previously referenced the detached entity will continue to reference it.- Specified by:
- detachin interface- EntityManager
- Parameters:
- entity- The instance to detach
 
- 
containsDescription copied from interface:EntityManagerCheck if the instance belongs to the current persistence context.- Specified by:
- containsin interface- EntityManager
- Parameters:
- entity- The instance to check
- Returns:
- True if the instance is managed, false otherwise
 
- 
closepublic void close()Description copied from interface:EntityManagerClose an application-managed EntityManager. After the close method has been invoked, all methods on the EntityManager instance and any Query objects obtained from it will throw the IllegalStateException except for getTransaction and isOpen (which will return false). If this method is called when the EntityManager is associated with an active transaction, the persistence context remains managed until the transaction completes.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- EntityManager
 
- 
isOpenpublic boolean isOpen()Description copied from interface:EntityManagerDetermine whether the EntityManager is open.- Specified by:
- isOpenin interface- EntityManager
- Returns:
- true until the EntityManager has been closed.
 
- 
getTransactionDescription copied from interface:EntityManagerReturn the resource-level transaction object. The EntityTransaction instance may be used serially to begin and commit multiple transactions.- Specified by:
- getTransactionin interface- EntityManager
- Returns:
- EntityTransaction instance
 
- 
getEntityManagerFactoryDescription copied from interface:EntityManagerReturn the entity manager factory for the entity manager.- Specified by:
- getEntityManagerFactoryin interface- EntityManager
- Returns:
- EntityManagerFactory instance
 
- 
getMetamodelDescription copied from interface:EntityManagerReturn an instance of Metamodel interface for access to the metamodel of the persistence unit.- Specified by:
- getMetamodelin interface- EntityManager
- Returns:
- Metamodel instance
 
- 
isLoaded- Specified by:
- isLoadedin interface- AbstractEntityManager
 
- 
isLoaded- Specified by:
- isLoadedin interface- AbstractEntityManager
 
- 
createQueryDescription copied from interface:EntityManagerCreate an instance of Query for executing a Java Persistence query language statement.- Specified by:
- createQueryin interface- EntityManager
- Parameters:
- qlString- a Java Persistence query string
- Returns:
- the new query instance
 
- 
createQueryDescription copied from interface:EntityManagerCreate an instance of TypedQuery for executing a criteria query.- Specified by:
- createQueryin interface- EntityManager
- Parameters:
- criteriaQuery- criteria query object
- Returns:
- the new query instance
 
- 
createQueryDescription copied from interface:EntityManagerCreates an instance of query for executing Java persistence query language statement.- Specified by:
- createQueryin interface- EntityManager
- Parameters:
- query- query string
- resultClass- result type
- Returns:
- the new query instance
 
- 
createNativeQueryDescription copied from interface:EntityManagerCreate an instance of Query for executing a native SPARQL(-DL) query in SPARQL syntax.- Specified by:
- createNativeQueryin interface- EntityManager
- Parameters:
- sparqlString- a native SPARQL query string
- Returns:
- the new query instance
 
- 
createNativeQueryDescription copied from interface:EntityManagerCreate an instance of Query for executing a native SPARQL(-DL) query returning only specific object type.- Specified by:
- createNativeQueryin interface- EntityManager
- Parameters:
- sparqlString- a native SQL query string
- resultClass- the class of the resulting instance(s)
- Returns:
- the new query instance
 
- 
createNativeQueryDescription copied from interface:EntityManagerCreate an instance of Query for executing a native SPARQL query.- Specified by:
- createNativeQueryin interface- EntityManager
- Parameters:
- sparqlString- a native SQL query string
- resultSetMapping- the name of the result set mapping
- Returns:
- the new query instance
 
- 
createNamedQueryDescription copied from interface:EntityManagerCreate an instance of Query for executing a named query (in native SPARQL).- Specified by:
- createNamedQueryin interface- EntityManager
- Parameters:
- name- the name of a query defined in metadata
- Returns:
- the new query instance
 
- 
createNamedQueryDescription copied from interface:EntityManagerCreate an instance of TypedQuery for executing a SPARQL named query.The select list of the query must contain only a single item, which must be assignable to the type specified by the resultClass argument. - Specified by:
- createNamedQueryin interface- EntityManager
- Parameters:
- name- the name of a query defined in metadata
- resultClass- the type of the query result
- Returns:
- the new query instance
 
- 
isConsistentDescription copied from interface:EntityManagerChecks consistency of the specified context.The context URI can be null, which indicates that consistency of the whole repository should be verified.- Specified by:
- isConsistentin interface- EntityManager
- Parameters:
- context- Context URI, can be- null
- Returns:
- trueif consistent,- falseotherwise
 
- 
getContextsDescription copied from interface:EntityManagerReturns a list of repository contexts available to this entity manager.- Specified by:
- getContextsin interface- EntityManager
- Returns:
- List of repository context URIs
 
- 
isInferredDescription copied from interface:EntityManagerChecks whether the specified attribute value of the specified entity is inferred in the underlying repository.Note that given the nature of the repository implementation, this method may return true if the corresponding statement is both inferred and asserted. Also note that this method will use the descriptor associated with the specified entity in this persistence context to resolve the repository context, but some underlying repositories do not store inferences in data contexts, so the attribute context may be ignored. - Specified by:
- isInferredin interface- EntityManager
- Parameters:
- entity- Entity whose attribute to examine. Must be managed by this persistence context
- attribute- Attribute whose value to examine
- value- The value whose inference to examine
- Returns:
- trueif the entity attribute value is inferred,- falseotherwise
 
- 
getCriteriaBuilderDescription copied from interface:EntityManagerReturn a criteriaFactory for making CriteriaQuery.- Specified by:
- getCriteriaBuilderin interface- EntityManager
- Returns:
- CriteriaBuilder instance
 
- 
unwrapDescription copied from interface:EntityManagerReturn an object of the specified type to allow access to the provider-specific API. If the provider's EntityManager implementation does not support the specified class, theOWLPersistenceExceptionis thrown.- Specified by:
- unwrapin interface- EntityManager
- Specified by:
- unwrapin interface- Wrapper
- Parameters:
- cls- The class of the object to be returned. This can be also an implementation of the underlying driver
- Returns:
- an instance of the specified class
 
- 
getDelegateDescription copied from interface:EntityManagerReturn the underlying provider object for the EntityManager, if available. The result of this method is implementation specific.- Specified by:
- getDelegatein interface- EntityManager
- Returns:
- underlying provider object for EntityManager
 
- 
finalize
- 
getCurrentPersistenceContextDescription copied from interface:AbstractEntityManagerReturn the UnitOfWork that holds the current persistence context.- Specified by:
- getCurrentPersistenceContextin interface- AbstractEntityManager
- Returns:
- UnitOfWork
 
- 
removeCurrentPersistenceContextpublic void removeCurrentPersistenceContext()Called from EntityTransaction in case of a rollback. Releasing the UoW is up to the EntityTransaction.- Specified by:
- removeCurrentPersistenceContextin interface- AbstractEntityManager
 
- 
transactionStartedDescription copied from interface:AbstractEntityManagerLet the managing server session know that a transaction has been started.- Specified by:
- transactionStartedin interface- AbstractEntityManager
- Parameters:
- t- The entity transaction that was started.
 
- 
transactionFinishedDescription copied from interface:AbstractEntityManagerLet the managing server session know that a transaction has finished successfully.- Specified by:
- transactionFinishedin interface- AbstractEntityManager
- Parameters:
- t- The committed entity transaction.
 
- 
getConfigurationDescription copied from interface:ConfigurationHolderGets provider configuration.- Specified by:
- getConfigurationin interface- ConfigurationHolder
- Returns:
- Configuration
 
- 
getPropertiesDescription copied from interface:EntityManagerGet the properties and hints and associated values that are in effect for the entity manager.Changing the contents of the map does not change the configuration in effect. - Specified by:
- getPropertiesin interface- EntityManager
- Returns:
- Map of properties and hints in effect for entity manager
 
- 
setPropertyDescription copied from interface:EntityManagerSet an entity manager property or hint.If a vendor-specific property or hint is not recognized, it is silently ignored. - Specified by:
- setPropertyin interface- EntityManager
- Parameters:
- propertyName- Name of property or hint
- value- Value for property or hint
 
- 
createDescriptorDescription copied from interface:EntityManagerCreates aDescriptorfor instances of the specified entity class.- Specified by:
- createDescriptorin interface- EntityManager
- Parameters:
- cls- Entity class to create descriptor for
- Returns:
- Entity descriptor
 
 
-