public class AmberConnection extends java.lang.Object implements Synchronization, EntityManager
Modifier and Type | Method and Description |
---|---|
void |
addCompletion(AmberCompletion completion)
Adds a completion
|
void |
addEntity(Entity entity) |
Entity |
addNewEntity(java.lang.Class cl,
java.lang.Object key)
Adds a new entity for the given class name and key.
|
void |
afterCommit(boolean isCommit)
Commits a transaction.
|
void |
afterCompletion(int status)
Callback after a utrans commit.
|
void |
beforeCommit()
Called before the commit phase
|
void |
beforeCompletion()
Callback before a utrans commit.
|
void |
begin(Transaction xa)
Callback when the user transaction begins
|
void |
beginTransaction()
Starts a transaction.
|
void |
cleanup()
Cleans up the connection.
|
void |
clear()
Clears the connection
|
void |
close()
Closes the context.
|
static void |
close(java.sql.ResultSet rs) |
void |
closeStatement(java.lang.String sql)
Closes a statement.
|
void |
commit()
Commits a transaction.
|
boolean |
contains(java.lang.Object obj)
Loads the object based on itself.
|
void |
create(AmberEntityHome home,
java.lang.Object obj)
Saves the object.
|
void |
create(java.lang.Object obj)
Saves the object.
|
void |
create(java.lang.String homeName,
java.lang.Object obj)
Saves the object.
|
Query |
createNamedQuery(java.lang.String name)
Creates an instance of the named query
|
<T> TypedQuery<T> |
createNamedQuery(java.lang.String name,
java.lang.Class<T> resultClass)
Creates a named query.
|
Query |
createNativeQuery(java.lang.String sql)
Creates an instance of the named query
|
Query |
createNativeQuery(java.lang.String sql,
java.lang.Class type)
Creates an instance of the native query
|
Query |
createNativeQuery(java.lang.String sql,
java.lang.String map)
Creates an instance of the named query
|
<T> TypedQuery<T> |
createQuery(CriteriaQuery<T> criteriaQuery)
Creates a TypedQuery for a criteria
|
Query |
createQuery(java.lang.String sql)
Creates a query.
|
<T> TypedQuery<T> |
createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
Creates a TypedQuery for a criteria
|
void |
delete(Entity entity)
Deletes the object.
|
void |
detach()
Detach after non-xa.
|
void |
detach(java.lang.Object entity)
Clears the entity
|
void |
expire()
Expires the entities
|
void |
finalize()
Finalizer.
|
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Find by the primary key.
|
<T> T |
find(java.lang.Class<T> entityCLass,
java.lang.Object primaryKey,
LockModeType lockMode)
Find based on the primary key.
|
<T> T |
find(java.lang.Class<T> entityCLass,
java.lang.Object primaryKey,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find based on the primary key.
|
<T> T |
find(java.lang.Class<T> entityCLass,
java.lang.Object primaryKey,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find based on the primary key.
|
java.util.List |
find(java.lang.String hsql)
Select a list of objects with a Hibernate query.
|
EntityItem |
findEntityItem(java.lang.String name,
java.lang.Object key)
Loads the object with the given class.
|
void |
flush()
Flushes managed entities.
|
void |
flushNoChecks()
Flushes managed entities.
|
void |
freeConnection()
Frees the connection.
|
AmberPersistenceUnit |
getAmberManager()
Returns the amber manager.
|
int |
getCacheChunkSize()
Returns the cache chunk size.
|
Entity |
getCacheEntity(java.lang.Class cl,
java.lang.Object pk) |
Entity |
getCacheEntity(java.lang.Class cl,
java.lang.Object pk,
boolean isDebug) |
Entity |
getCacheEntity(Entity entity) |
Entity |
getCacheEntity(Entity entity,
boolean isDebug) |
java.sql.Connection |
getConnection()
Returns the connection.
|
CriteriaBuilder |
getCriteriaBuilder()
Returns a CriteriaBuilder to create CriteriaQuery objects.
|
java.lang.Object |
getDelegate()
Gets the delegate.
|
Entity |
getEntity(java.lang.Class cl,
java.lang.Object key)
Matches the entity.
|
Entity |
getEntity(Entity entity)
Returns the context entity that corresponds to the
entity passed in.
|
Entity |
getEntity(EntityItem item)
Returns the entity for the connection.
|
Entity |
getEntity(int index) |
Entity |
getEntityLazy(EntityItem item)
Returns the entity for the connection.
|
EntityManagerFactory |
getEntityManagerFactory()
Returns the owning factory
|
FlushModeType |
getFlushMode()
Returns the flush mode.
|
LockModeType |
getLockMode(java.lang.Object entity)
Returns the lock mode for the entity
|
Metamodel |
getMetamodel()
Returns the Metamodel interface for the persistence unit.
|
AmberPersistenceUnit |
getPersistenceUnit()
Returns the persistence unit.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Returns the properties for the entity manager
|
ResultSetCacheChunk |
getQueryCacheChunk(java.lang.String sql,
java.lang.Object[] args,
int startRow)
Returns the cache chunk.
|
java.sql.ResultSetMetaData |
getQueryMetaData()
Returns the result set meta data from cache.
|
<T> T |
getReference(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Find by the primary key.
|
Entity |
getSubEntity(java.lang.Class cl,
java.lang.Object key) |
EntityItem |
getSubEntityCacheItem(java.lang.Class cl,
java.lang.Object key)
Gets the cache item referenced by __caucho_item
from an entity of class/subclass cl.
|
EntityTransaction |
getTransaction()
Returns the transaction.
|
Entity |
getTransactionEntity(java.lang.Class cl,
java.lang.Object key) |
Entity |
getTransactionEntity(int index) |
void |
initJta() |
void |
initThreadConnection()
Set true for a threaded connection.
|
boolean |
isActiveTransaction()
Returns true if a transaction is active or
this persistence context is extended.
|
boolean |
isCacheEntity(Entity entity) |
boolean |
isInTransaction()
Returns true if a transaction is active.
|
boolean |
isJPA()
Returns true for JPA.
|
boolean |
isOpen()
Returns true if open.
|
void |
joinTransaction()
Joins the transaction.
|
java.lang.Object |
load(java.lang.Class cl,
long intKey)
Loads the object based on the class and primary key.
|
java.lang.Object |
load(java.lang.Class cl,
java.lang.Object key,
boolean isEager) |
java.lang.Object |
load(java.lang.String entityName,
java.lang.Object key)
Loads the object based on the class and primary key.
|
EntityItem |
loadCacheItem(java.lang.Class cl,
java.lang.Object key,
AmberEntityHome entityHome) |
Entity |
loadEntity(java.lang.Class cl,
java.lang.Object key,
boolean isEager)
Adds a new entity for the given class name and key.
|
Entity |
loadFromHome(java.lang.String name,
java.lang.Object key)
Loads the object with the given class.
|
java.lang.Object |
loadLazy(java.lang.Class cl,
long intKey)
Loads the object based on the class and primary key.
|
Entity |
loadLazy(java.lang.Class cl,
java.lang.String name,
java.lang.Object key)
Loads the object with the given class.
|
Entity |
loadLazy(java.lang.String className,
java.lang.String name,
java.lang.Object key)
Loads the object with the given class.
|
java.lang.Object |
loadProxy(EntityItem entityItem)
Loads the CMP 2.1 object for the given entityItem
|
java.lang.Object |
loadProxy(EntityType type,
java.lang.Object key)
Loads the object with the given class.
|
java.lang.Object |
loadProxy(java.lang.String name,
java.lang.Object key)
Loads the object with the given class.
|
void |
lock(java.lang.Object entity,
LockModeType lockMode)
Locks the object.
|
void |
lock(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Sets the lock mode for an entity.
|
java.lang.Object |
makePersistent(java.lang.Object obj)
Loads the object based on itself.
|
<T> T |
merge(T entityT)
Merges the state of the entity into the current context.
|
Entity |
mergeDetachedEntity(Entity newEntity) |
AbstractQuery |
parseQuery(java.lang.String sql,
boolean isLazy)
Creates a query object from a query string.
|
void |
persist(java.lang.Object entityObject)
Makes the instance managed.
|
java.lang.Object |
persistFromCascade(java.lang.Object o)
Makes the instance managed called
from cascading operations.
|
void |
popDepth()
Pops the depth.
|
java.sql.PreparedStatement |
prepareInsertStatement(java.lang.String sql,
boolean isGeneratedId)
Prepares an insert statement.
|
AmberQuery |
prepareLazyQuery(java.lang.String queryString)
Creates a query object from a query string.
|
AmberQuery |
prepareQuery(java.lang.String queryString)
Creates a query object from a query string.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Prepares a statement.
|
AmberQuery |
prepareUpdate(java.lang.String queryString)
Creates a query object from a query string.
|
void |
pushDepth()
Pushes the depth.
|
void |
putQueryCacheChunk(java.lang.String sql,
java.lang.Object[] args,
int startRow,
ResultSetCacheChunk cacheChunk,
java.sql.ResultSetMetaData cacheMetaData)
Sets the cache chunk.
|
java.sql.ResultSet |
query(java.lang.String hsql)
Select a list of objects with a Hibernate query.
|
<T> T |
recursiveMerge(T entityT)
Recursively merges the state of the entity into the current context.
|
void |
refresh(java.lang.Object entity)
Refresh the state of the instance from the database.
|
void |
refresh(java.lang.Object entity,
LockModeType lockMode)
Update the state of the instance from the database.
|
void |
refresh(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Update the state of the instance from the database.
|
void |
refresh(java.lang.Object entity,
java.util.Map<java.lang.String,java.lang.Object> properties)
Update the state of the instance from the database.
|
void |
register(AmberCollection query)
Registers a collection.
|
void |
remove(java.lang.Object entity)
Remove the instance.
|
boolean |
removeEntity(Entity entity)
Removes an entity.
|
void |
rollback()
Rollbacks a transaction.
|
PersistenceException |
rollback(java.lang.Exception e) |
EntityItem |
setEntityItem(java.lang.String name,
java.lang.Object key,
EntityItem item)
Loads the object with the given class.
|
void |
setExtended(boolean isExtended)
Sets the extended type.
|
void |
setFlushMode(FlushModeType mode)
Returns the flush mode.
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object value)
Sets properties for the entity manager
|
void |
setTransactionalState(Entity entity) |
void |
setXA(boolean isXA)
Sets XA.
|
boolean |
shouldRetrieveFromCache()
Returns true when cache items can be used.
|
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> cls)
Returns the object of the type for a provider-specific API
|
void |
update(Entity entity)
Updates the object.
|
void |
update(java.lang.Object obj)
Updates the database with the values in object.
|
int |
update(java.lang.String hsql)
Updates the database with a query
|
public AmberPersistenceUnit getPersistenceUnit()
public boolean isJPA()
public void initThreadConnection()
public void initJta()
public void persist(java.lang.Object entityObject)
persist
in interface EntityManager
public java.lang.Object persistFromCascade(java.lang.Object o)
public <T> T merge(T entityT)
merge
in interface EntityManager
public void remove(java.lang.Object entity)
remove
in interface EntityManager
public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
find
in interface EntityManager
public <T> T getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey) throws EntityNotFoundException, java.lang.IllegalArgumentException
getReference
in interface EntityManager
EntityNotFoundException
java.lang.IllegalArgumentException
public void clear()
clear
in interface EntityManager
public Query createQuery(java.lang.String sql)
createQuery
in interface EntityManager
public Query createNamedQuery(java.lang.String name)
createNamedQuery
in interface EntityManager
public Query createNativeQuery(java.lang.String sql)
createNativeQuery
in interface EntityManager
public Query createNativeQuery(java.lang.String sql, java.lang.String map)
createNativeQuery
in interface EntityManager
public Query createNativeQuery(java.lang.String sql, java.lang.Class type)
createNativeQuery
in interface EntityManager
public void refresh(java.lang.Object entity)
refresh
in interface EntityManager
public FlushModeType getFlushMode()
getFlushMode
in interface EntityManager
public void setExtended(boolean isExtended)
public void setFlushMode(FlushModeType mode)
setFlushMode
in interface EntityManager
public void lock(java.lang.Object entity, LockModeType lockMode)
lock
in interface EntityManager
public EntityTransaction getTransaction()
getTransaction
in interface EntityManager
public boolean isOpen()
isOpen
in interface EntityManager
public void joinTransaction()
joinTransaction
in interface EntityManager
public java.lang.Object getDelegate()
getDelegate
in interface EntityManager
public void close()
close
in interface EntityManager
public AmberPersistenceUnit getAmberManager()
public void register(AmberCollection query)
public void addCompletion(AmberCompletion completion)
public boolean isActiveTransaction()
public boolean isInTransaction()
public int getCacheChunkSize()
public java.lang.Object load(java.lang.Class cl, java.lang.Object key, boolean isEager) throws AmberException
AmberException
public EntityItem loadCacheItem(java.lang.Class cl, java.lang.Object key, AmberEntityHome entityHome) throws AmberException
AmberException
public java.lang.Object load(java.lang.String entityName, java.lang.Object key) throws AmberException
AmberException
public Entity getEntity(EntityItem item)
public Entity getEntityLazy(EntityItem item)
public java.lang.Object makePersistent(java.lang.Object obj) throws java.sql.SQLException
java.sql.SQLException
public Entity loadLazy(java.lang.Class cl, java.lang.String name, java.lang.Object key)
public Entity loadLazy(java.lang.String className, java.lang.String name, java.lang.Object key)
public EntityItem findEntityItem(java.lang.String name, java.lang.Object key)
public EntityItem setEntityItem(java.lang.String name, java.lang.Object key, EntityItem item)
public Entity loadFromHome(java.lang.String name, java.lang.Object key)
name
- the class name.key
- the key.public java.lang.Object loadProxy(java.lang.String name, java.lang.Object key)
public java.lang.Object loadProxy(EntityType type, java.lang.Object key)
public java.lang.Object loadProxy(EntityItem entityItem)
public java.lang.Object load(java.lang.Class cl, long intKey) throws AmberException
AmberException
public java.lang.Object loadLazy(java.lang.Class cl, long intKey) throws AmberException
AmberException
public Entity getEntity(java.lang.Class cl, java.lang.Object key)
public Entity getEntity(int index)
public Entity getEntity(Entity entity)
public Entity getSubEntity(java.lang.Class cl, java.lang.Object key)
public EntityItem getSubEntityCacheItem(java.lang.Class cl, java.lang.Object key)
public Entity getTransactionEntity(java.lang.Class cl, java.lang.Object key)
public Entity getTransactionEntity(int index)
public Entity addNewEntity(java.lang.Class cl, java.lang.Object key) throws java.lang.InstantiationException, java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.IllegalAccessException
public Entity loadEntity(java.lang.Class cl, java.lang.Object key, boolean isEager)
public boolean removeEntity(Entity entity)
public boolean contains(java.lang.Object obj)
contains
in interface EntityManager
public void begin(Transaction xa)
public void beginTransaction() throws java.sql.SQLException
java.sql.SQLException
public void setXA(boolean isXA)
public void commit() throws java.sql.SQLException
java.sql.SQLException
public void beforeCompletion()
beforeCompletion
in interface Synchronization
public void afterCompletion(int status)
afterCompletion
in interface Synchronization
public void beforeCommit() throws java.sql.SQLException
java.sql.SQLException
public void afterCommit(boolean isCommit)
public PersistenceException rollback(java.lang.Exception e)
public void rollback() throws java.sql.SQLException
java.sql.SQLException
public void flush()
flush
in interface EntityManager
public void flushNoChecks()
public void expire() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public void closeStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public static void close(java.sql.ResultSet rs)
public java.sql.PreparedStatement prepareInsertStatement(java.lang.String sql, boolean isGeneratedId) throws java.sql.SQLException
java.sql.SQLException
public void update(java.lang.Object obj)
obj
- the object to updatepublic void create(java.lang.Object obj) throws java.sql.SQLException
obj
- the object to createjava.sql.SQLException
public void create(java.lang.String homeName, java.lang.Object obj) throws java.sql.SQLException
obj
- the object to createjava.sql.SQLException
public void create(AmberEntityHome home, java.lang.Object obj) throws java.sql.SQLException
obj
- the object to createjava.sql.SQLException
public void update(Entity entity)
public void delete(Entity entity) throws java.sql.SQLException
entity
- the object to deletejava.sql.SQLException
public AmberQuery prepareQuery(java.lang.String queryString) throws AmberException
queryString
- a Hibernate queryAmberException
public AmberQuery prepareLazyQuery(java.lang.String queryString) throws AmberException
queryString
- a Hibernate queryAmberException
public AmberQuery prepareUpdate(java.lang.String queryString) throws AmberException
queryString
- a Hibernate queryAmberException
public AbstractQuery parseQuery(java.lang.String sql, boolean isLazy) throws AmberException
sql
- a Hibernate queryAmberException
public java.sql.ResultSet query(java.lang.String hsql) throws java.sql.SQLException
hsql
- the hibernate queryjava.sql.SQLException
public ResultSetCacheChunk getQueryCacheChunk(java.lang.String sql, java.lang.Object[] args, int startRow)
sql
- the SQL for the cache chunkargs
- the filled parameters for the cache chunkstartRow
- the starting row for the cache chunkpublic java.sql.ResultSetMetaData getQueryMetaData()
public void putQueryCacheChunk(java.lang.String sql, java.lang.Object[] args, int startRow, ResultSetCacheChunk cacheChunk, java.sql.ResultSetMetaData cacheMetaData)
sql
- the SQL for the cache chunkargs
- the filled parameters for the cache chunkstartRow
- the starting row for the cache chunkcacheChunk
- the new value of the cache chunkpublic int update(java.lang.String hsql) throws java.sql.SQLException
hsql
- the hibernate queryjava.sql.SQLException
public java.util.List find(java.lang.String hsql) throws java.sql.SQLException
hsql
- the hibernate queryjava.sql.SQLException
public void cleanup()
public void pushDepth()
public void popDepth()
public void freeConnection()
public java.lang.String toString()
toString
in class java.lang.Object
public void finalize()
finalize
in class java.lang.Object
public boolean shouldRetrieveFromCache()
public void setTransactionalState(Entity entity)
public boolean isCacheEntity(Entity entity)
public Entity getCacheEntity(java.lang.Class cl, java.lang.Object pk)
public Entity getCacheEntity(java.lang.Class cl, java.lang.Object pk, boolean isDebug)
public void detach()
public <T> T recursiveMerge(T entityT)
public void addEntity(Entity entity)
public <T> TypedQuery<T> createNamedQuery(java.lang.String name, java.lang.Class<T> resultClass)
EntityManager
createNamedQuery
in interface EntityManager
public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)
EntityManager
createQuery
in interface EntityManager
public <T> TypedQuery<T> createQuery(java.lang.String qlString, java.lang.Class<T> resultClass)
EntityManager
createQuery
in interface EntityManager
public void detach(java.lang.Object entity)
EntityManager
detach
in interface EntityManager
public <T> T find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, java.util.Map<java.lang.String,java.lang.Object> properties)
EntityManager
find
in interface EntityManager
public <T> T find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, LockModeType lockMode)
EntityManager
find
in interface EntityManager
public <T> T find(java.lang.Class<T> entityCLass, java.lang.Object primaryKey, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
EntityManager
find
in interface EntityManager
public CriteriaBuilder getCriteriaBuilder()
EntityManager
getCriteriaBuilder
in interface EntityManager
public EntityManagerFactory getEntityManagerFactory()
EntityManager
getEntityManagerFactory
in interface EntityManager
public LockModeType getLockMode(java.lang.Object entity)
EntityManager
getLockMode
in interface EntityManager
public Metamodel getMetamodel()
EntityManager
getMetamodel
in interface EntityManager
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
EntityManager
getProperties
in interface EntityManager
public void lock(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
EntityManager
lock
in interface EntityManager
public void refresh(java.lang.Object entity, java.util.Map<java.lang.String,java.lang.Object> properties)
EntityManager
refresh
in interface EntityManager
public void refresh(java.lang.Object entity, LockModeType lockMode)
EntityManager
refresh
in interface EntityManager
public void refresh(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
EntityManager
refresh
in interface EntityManager
public void setProperty(java.lang.String propertyName, java.lang.Object value)
EntityManager
setProperty
in interface EntityManager
public <T> T unwrap(java.lang.Class<T> cls)
EntityManager
unwrap
in interface EntityManager