public class FullTextEntityManagerImpl extends Object implements FullTextEntityManager, Serializable
| Constructor and Description |
|---|
FullTextEntityManagerImpl(EntityManager em) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the persistence context, causing all managed
entities to become detached.
|
void |
close()
Close an application-managed entity manager.
|
boolean |
contains(Object entity)
Check if the instance is a managed entity instance belonging
to the current persistence context.
|
FullTextQuery |
createFullTextQuery(org.apache.lucene.search.Query luceneQuery,
Class<?>... entities)
Create a fulltext query on top of a native Lucene query returning the matching objects
of type
entities and their respective subclasses. |
MassIndexer |
createIndexer(Class<?>... types)
Creates a MassIndexer to rebuild the indexes of some
or all indexed entity types.
|
Query |
createNamedQuery(String name)
Create an instance of
Query for executing a named query
(in the Java Persistence query language or in native SQL). |
<T> TypedQuery<T> |
createNamedQuery(String name,
Class<T> resultClass)
Create an instance of
TypedQuery for executing a
Java Persistence query language named query. |
Query |
createNativeQuery(String sqlString)
Create an instance of
Query for executing
a native SQL statement, e.g., for update or delete. |
Query |
createNativeQuery(String sqlString,
Class resultClass)
Create an instance of
Query for executing
a native SQL query. |
Query |
createNativeQuery(String sqlString,
String resultSetMapping)
Create an instance of
Query for executing
a native SQL query. |
<T> TypedQuery<T> |
createQuery(CriteriaQuery<T> criteriaQuery)
Create an instance of
TypedQuery for executing a
criteria query. |
Query |
createQuery(String ejbqlString)
Create an instance of
Query for executing a
Java Persistence query language statement. |
<T> TypedQuery<T> |
createQuery(String qlString,
Class<T> resultClass)
Create an instance of
TypedQuery for executing a
Java Persistence query language statement. |
void |
detach(Object entity)
Remove the given entity from the persistence context, causing
a managed entity to become detached.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find by primary key.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
LockModeType lockModeType)
Find by primary key and lock.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
LockModeType lockModeType,
Map<String,Object> hints)
Find by primary key and lock, using the specified properties.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
Map<String,Object> hints)
Find by primary key, using the specified properties.
|
void |
flush()
Synchronize the persistence context to the
underlying database.
|
void |
flushToIndexes()
Flush all index changes forcing Hibernate Search to apply all changes to the index not waiting for the batch limit.
|
CriteriaBuilder |
getCriteriaBuilder()
Return an instance of
CriteriaBuilder for the creation of
CriteriaQuery objects. |
Object |
getDelegate()
Return the underlying provider object for the
EntityManager,
if available. |
EntityManagerFactory |
getEntityManagerFactory()
Return the entity manager factory for the entity manager.
|
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained
in the persistence context.
|
LockModeType |
getLockMode(Object entity)
Get the current lock mode for the entity instance.
|
Metamodel |
getMetamodel()
Return an instance of
Metamodel interface for access to the
metamodel of the persistence unit. |
Map<String,Object> |
getProperties()
Get the properties and hints and associated values that are in effect
for the entity manager.
|
<T> T |
getReference(Class<T> entityClass,
Object primaryKey)
Get an instance, whose state may be lazily fetched.
|
org.hibernate.search.SearchFactory |
getSearchFactory() |
EntityTransaction |
getTransaction()
Return the resource-level
EntityTransaction object. |
<T> void |
index(T entity)
Force the (re)indexing of a given managed object.
|
boolean |
isOpen()
Determine whether the entity manager is open.
|
void |
joinTransaction()
Indicate to the entity manager that a JTA transaction is
active.
|
void |
lock(Object entity,
LockModeType lockMode)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type.
|
void |
lock(Object entity,
LockModeType lockModeType,
Map<String,Object> hints)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type and with specified
properties.
|
<T> T |
merge(T entity)
Merge the state of the given entity into the
current persistence context.
|
void |
persist(Object entity)
Make an instance managed and persistent.
|
<T> void |
purge(Class<T> entityType,
Serializable id)
Remove the entity with the type
entityType and the identifier id from the index. |
<T> void |
purgeAll(Class<T> entityType)
Remove all entities from of particular class and all its subclasses from the index.
|
void |
refresh(Object entity)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any.
|
void |
refresh(Object entity,
LockModeType lockModeType)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any, and
lock it with respect to given lock mode type.
|
void |
refresh(Object entity,
LockModeType lockModeType,
Map<String,Object> hints)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any, and
lock it with respect to given lock mode type and with
specified properties.
|
void |
refresh(Object entity,
Map<String,Object> hints)
Refresh the state of the instance from the database, using
the specified properties, and overwriting changes made to
the entity, if any.
|
void |
remove(Object entity)
Remove the entity instance.
|
void |
setFlushMode(FlushModeType flushMode)
Set the flush mode that applies to all objects contained
in the persistence context.
|
void |
setProperty(String key,
Object value)
Set an entity manager property or hint.
|
<T> T |
unwrap(Class<T> type)
Return an object of the specified type to allow access to the
provider-specific API.
|
public FullTextEntityManagerImpl(EntityManager em)
public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities)
FullTextEntityManagerentities and their respective subclasses.createFullTextQuery in interface FullTextEntityManagerluceneQuery - The native Lucene query to be rn against the Lucene index.entities - List of classes for type filtering. The query result will only return entities of
the specified types and their respective subtype. If no class is specified no type filtering will take place.FullTextQuery wrapping around the native Lucene wuery.public <T> void index(T entity)
FullTextEntityManagerindex in interface FullTextEntityManagerentity - The entity to index - must not be null.public org.hibernate.search.SearchFactory getSearchFactory()
getSearchFactory in interface FullTextEntityManagerSearchFactory instance.public <T> void purge(Class<T> entityType, Serializable id)
FullTextEntityManagerentityType and the identifier id from the index.
If id == null all indexed entities of this type and its indexed subclasses are deleted. In this
case this method behaves like FullTextEntityManager.purgeAll(Class).purge in interface FullTextEntityManagerentityType - The type of the entity to delete.id - The id of the entity to delete.public <T> void purgeAll(Class<T> entityType)
FullTextEntityManagerpurgeAll in interface FullTextEntityManagerentityType - The class of the entities to remove.public void flushToIndexes()
FullTextEntityManagerflushToIndexes in interface FullTextEntityManagerpublic void persist(Object entity)
EntityManagerpersist in interface EntityManagerentity - entity instancepublic <T> T merge(T entity)
EntityManagermerge in interface EntityManagerentity - entity instancepublic void remove(Object entity)
EntityManagerremove in interface EntityManagerentity - entity instancepublic <T> T find(Class<T> entityClass, Object primaryKey)
EntityManagerfind in interface EntityManagerentityClass - entity classprimaryKey - primary keypublic <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> hints)
EntityManagerfind in interface EntityManagerentityClass - entity classprimaryKey - primary keyhints - standard and vendor-specific properties
and hintspublic <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType)
EntityManager If the entity is found within the persistence context and the
lock mode type is pessimistic and the entity has a version
attribute, the persistence provider must perform optimistic
version checks when obtaining the database lock. If these
checks fail, the OptimisticLockException will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the database
locking failure causes only statement-level rollback
find in interface EntityManagerentityClass - entity classprimaryKey - primary keylockModeType - lock modepublic <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String,Object> hints)
EntityManager If the entity is found
within the persistence context and the lock mode type
is pessimistic and the entity has a version attribute, the
persistence provider must perform optimistic version checks
when obtaining the database lock. If these checks fail,
the OptimisticLockException will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
find in interface EntityManagerentityClass - entity classprimaryKey - primary keylockModeType - lock modehints - standard and vendor-specific properties
and hintspublic <T> T getReference(Class<T> entityClass, Object primaryKey)
EntityManagerEntityNotFoundException is thrown when the instance
state is first accessed. (The persistence provider runtime is
permitted to throw the EntityNotFoundException when
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.getReference in interface EntityManagerentityClass - entity classprimaryKey - primary keypublic void flush()
EntityManagerflush in interface EntityManagerpublic void setFlushMode(FlushModeType flushMode)
EntityManagersetFlushMode in interface EntityManagerflushMode - flush modepublic FlushModeType getFlushMode()
EntityManagergetFlushMode in interface EntityManagerpublic void lock(Object entity, LockModeType lockMode)
EntityManagerIf a pessimistic lock mode type is specified and the entity
contains a version attribute, the persistence provider must
also perform optimistic version checks when obtaining the
database lock. If these checks fail, the
OptimisticLockException will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the database
locking failure causes only statement-level rollback
lock in interface EntityManagerentity - entity instancelockMode - lock modepublic void lock(Object entity, LockModeType lockModeType, Map<String,Object> hints)
EntityManagerIf a pessimistic lock mode type is specified and the entity
contains a version attribute, the persistence provider must
also perform optimistic version checks when obtaining the
database lock. If these checks fail, the
OptimisticLockException will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
lock in interface EntityManagerentity - entity instancelockModeType - lock modehints - standard and vendor-specific properties
and hintspublic void refresh(Object entity)
EntityManagerrefresh in interface EntityManagerentity - entity instancepublic void refresh(Object entity, Map<String,Object> hints)
EntityManagerIf a vendor-specific property or hint is not recognized, it is silently ignored.
refresh in interface EntityManagerentity - entity instancehints - standard and vendor-specific properties
and hintspublic void refresh(Object entity, LockModeType lockModeType)
EntityManagerIf the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the
database locking failure causes only statement-level
rollback.
refresh in interface EntityManagerentity - entity instancelockModeType - lock modepublic void refresh(Object entity, LockModeType lockModeType, Map<String,Object> hints)
EntityManagerIf the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
refresh in interface EntityManagerentity - entity instancelockModeType - lock modehints - standard and vendor-specific properties
and hintspublic void clear()
EntityManagerclear in interface EntityManagerpublic void detach(Object entity)
EntityManagerdetach in interface EntityManagerentity - entity instancepublic boolean contains(Object entity)
EntityManagercontains in interface EntityManagerentity - entity instancepublic LockModeType getLockMode(Object entity)
EntityManagergetLockMode in interface EntityManagerentity - entity instancepublic void setProperty(String key, Object value)
EntityManagersetProperty in interface EntityManagerkey - name of property or hintvalue - value for property or hintpublic Map<String,Object> getProperties()
EntityManagergetProperties in interface EntityManagerpublic Query createQuery(String ejbqlString)
EntityManagerQuery for executing a
Java Persistence query language statement.createQuery in interface EntityManagerejbqlString - a Java Persistence query stringpublic <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)
EntityManagerTypedQuery for executing a
criteria query.createQuery in interface EntityManagercriteriaQuery - a criteria query objectpublic <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass)
EntityManagerTypedQuery for executing a
Java Persistence query language statement.
The select list of the query must contain only a single
item, which must be assignable to the type specified by
the resultClass argument.createQuery in interface EntityManagerqlString - a Java Persistence query stringresultClass - the type of the query resultpublic Query createNamedQuery(String name)
EntityManagerQuery for executing a named query
(in the Java Persistence query language or in native SQL).createNamedQuery in interface EntityManagername - the name of a query defined in metadatapublic <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass)
EntityManagerTypedQuery for executing a
Java Persistence query language 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.createNamedQuery in interface EntityManagername - the name of a query defined in metadataresultClass - the type of the query resultpublic Query createNativeQuery(String sqlString)
EntityManagerQuery for executing
a native SQL statement, e.g., for update or delete.createNativeQuery in interface EntityManagersqlString - a native SQL query stringpublic Query createNativeQuery(String sqlString, Class resultClass)
EntityManagerQuery for executing
a native SQL query.createNativeQuery in interface EntityManagersqlString - a native SQL query stringresultClass - the class of the resulting instance(s)public Query createNativeQuery(String sqlString, String resultSetMapping)
EntityManagerQuery for executing
a native SQL query.createNativeQuery in interface EntityManagersqlString - a native SQL query stringresultSetMapping - the name of the result set mappingpublic void joinTransaction()
EntityManagerjoinTransaction in interface EntityManagerpublic <T> T unwrap(Class<T> type)
EntityManagerEntityManager
implementation does not support the specified class, the
PersistenceException is thrown.unwrap in interface EntityManagertype - the class of the object to be returned. This is
normally either the underlying EntityManager implementation
class or an interface that it implements.public Object getDelegate()
EntityManagerEntityManager,
if available. The result of this method is implementation
specific. The unwrap method is to be preferred for new
applications.getDelegate in interface EntityManagerpublic void close()
EntityManagerEntityManager instance and any
Query and TypedQuery
objects obtained from it will throw the IllegalStateException
except for getProperties,
getTransaction, and isOpen (which will return false).
If this method is called when the entity manager is
associated with an active transaction, the persistence
context remains managed until the transaction completes.close in interface EntityManagerpublic boolean isOpen()
EntityManagerisOpen in interface EntityManagerpublic EntityTransaction getTransaction()
EntityManagerEntityTransaction object.
The EntityTransaction instance may be used serially to
begin and commit multiple transactions.getTransaction in interface EntityManagerpublic EntityManagerFactory getEntityManagerFactory()
EntityManagergetEntityManagerFactory in interface EntityManagerpublic CriteriaBuilder getCriteriaBuilder()
EntityManagerCriteriaBuilder for the creation of
CriteriaQuery objects.getCriteriaBuilder in interface EntityManagerpublic Metamodel getMetamodel()
EntityManagerMetamodel interface for access to the
metamodel of the persistence unit.getMetamodel in interface EntityManagerpublic MassIndexer createIndexer(Class<?>... types)
FullTextEntityManagercreateIndexer in interface FullTextEntityManagertypes - optionally restrict the operation to selected typesCopyright © 2018 JBoss by Red Hat. All rights reserved.