public abstract class AbstractTopiaPersistenceContext extends Object implements TopiaPersistenceContext
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractTopiaPersistenceContext.InternalTopiaHibernateSupport
This subclass of TopiaHibernateSupport is made to be used only internally within this persistence context.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
Flog used to check if this persistence context is closed
|
protected Map<Class<? extends TopiaEntity>,TopiaDao<? extends TopiaEntity>> |
daoCache
Already loaded DAO cache within this persistence context
|
protected TopiaFiresSupport |
firesSupport
Object that handles each event propagation.
|
protected AbstractTopiaPersistenceContext.InternalTopiaHibernateSupport |
hibernateSupport
This subclass of TopiaHibernateSupport is made to be used only internally within this persistence context.
|
protected HibernateTopiaReplicationSupport |
hibernateTopiaReplicationSupport |
protected TopiaJpaSupport |
jpaSupport
This instance of TopiaJpaSupport is created by the persistence context itself.
|
protected TopiaHibernateSessionRegistry |
sessionRegistry
The shared instance of TopiaHibernateSessionRegistry
|
protected TopiaSqlSupport |
sqlSupport
This instance of TopiaSqlSupport is created by the persistence context itself.
|
protected TopiaIdFactory |
topiaIdFactory
Used to affect a new topiaId when create is called.
|
| Constructor and Description |
|---|
AbstractTopiaPersistenceContext(AbstractTopiaPersistenceContextConstructorParameter parameter)
Creating a new TopiaPersistenceContext is equivalent to creating a new transaction
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkNotClosed() |
void |
close()
Closes the PersistenceContext.
|
void |
commit()
Applies all the modifications made to this context on the persistence device.
|
void |
delete(TopiaEntity entity)
Delete into this TopiaContext an entity created by another TopiaContext
|
<E extends TopiaEntity> |
deleteAll(Iterable<E> entities)
Delete into this TopiaContext an entities created by another TopiaContext
|
<E extends TopiaEntity> |
findByTopiaId(String topiaId)
Retrieve
TopiaEntity using its unique topiaId. |
<E extends TopiaEntity> |
getDao(Class<E> entityClass)
Get Dao for specified class.
|
<E extends TopiaEntity,D extends TopiaDao<E>> |
getDao(Class<E> entityClass,
Class<D> daoClass)
Get Dao for specified class.
|
TopiaHibernateSupport |
getHibernateSupport() |
protected HibernateTopiaReplicationSupport |
getHibernateTopiaReplicationSupport() |
TopiaSqlSupport |
getSqlSupport() |
TopiaFiresSupport |
getTopiaFiresSupport()
Get the currently configured
TopiaFiresSupport. |
TopiaIdFactory |
getTopiaIdFactory()
Get the currently configured
TopiaIdFactory. |
boolean |
isClosed()
Tells if the context is closed
|
void |
replicate(TopiaEntity entity)
Must replicate given entity in current database
|
void |
replicate(TopiaReplicationDestination topiaReplicationDestination,
Object... entityAndCondition)
Makes a replication of some entities from this context to the given
context without any entity modification.
|
<T extends TopiaEntity> |
replicateEntities(TopiaReplicationDestination topiaReplicationDestination,
List<T> entities)
Makes a replication of some entities from this context to the given
context without any entity modification.
|
<T extends TopiaEntity> |
replicateEntity(TopiaReplicationDestination topiaReplicationDestination,
T entity)
Replicate a given entity from this context to the given context.
|
void |
rollback()
Cancels all the modifications made to this context, coming back to the state when this transaction has been
created (using
TopiaApplicationContext.newPersistenceContext()) or previously rollbacked (using the
current method). |
protected void |
rollback0(boolean beginAfterRollback) |
protected void |
startTransaction() |
void |
update(TopiaEntity entity)
Add into this TopiaContext an entity created by another TopiaContext
|
protected Map<Class<? extends TopiaEntity>,TopiaDao<? extends TopiaEntity>> daoCache
protected HibernateTopiaReplicationSupport hibernateTopiaReplicationSupport
protected TopiaIdFactory topiaIdFactory
protected TopiaHibernateSessionRegistry sessionRegistry
protected TopiaFiresSupport firesSupport
protected AbstractTopiaPersistenceContext.InternalTopiaHibernateSupport hibernateSupport
protected TopiaJpaSupport jpaSupport
protected TopiaSqlSupport sqlSupport
protected boolean closed
public AbstractTopiaPersistenceContext(AbstractTopiaPersistenceContextConstructorParameter parameter)
parameter - everything needed (specific parameter-object)public TopiaHibernateSupport getHibernateSupport()
public TopiaSqlSupport getSqlSupport()
public TopiaIdFactory getTopiaIdFactory()
TopiaPersistenceContextTopiaIdFactory.getTopiaIdFactory in interface TopiaPersistenceContextTopiaIdFactory in useTopiaIdFactorypublic TopiaFiresSupport getTopiaFiresSupport()
TopiaPersistenceContextTopiaFiresSupport.getTopiaFiresSupport in interface TopiaPersistenceContextTopiaFiresSupport in useTopiaFiresSupportprotected void startTransaction()
throws TopiaException
TopiaExceptionprotected void checkNotClosed()
public <E extends TopiaEntity> E findByTopiaId(String topiaId)
TopiaPersistenceContextTopiaEntity using its unique topiaId.findByTopiaId in interface TopiaPersistenceContextE - type of entitytopiaId - unique identifier of the entity in all the application.public void update(TopiaEntity entity)
TopiaPersistenceContextupdate in interface TopiaPersistenceContextentity - the entity to addpublic void delete(TopiaEntity entity)
TopiaPersistenceContextdelete in interface TopiaPersistenceContextentity - the entity to deletepublic <E extends TopiaEntity> void deleteAll(Iterable<E> entities)
TopiaPersistenceContextdeleteAll in interface TopiaPersistenceContextE - type of entityentities - the entities to deletepublic <E extends TopiaEntity> TopiaDao<E> getDao(Class<E> entityClass)
TopiaDaoSuppliergetDao in interface TopiaDaoSupplierE - type of entityentityClass - type of entitypublic <E extends TopiaEntity,D extends TopiaDao<E>> D getDao(Class<E> entityClass, Class<D> daoClass)
TopiaDaoSuppliergetDao in interface TopiaDaoSupplierE - type of entityD - type of daoentityClass - type of entitydaoClass - the concrete dao class to usepublic void commit()
TopiaTransactionTopiaTransaction.commit in interface TopiaTransactionpublic void rollback()
TopiaTransactionTopiaApplicationContext.newPersistenceContext()) or previously rollbacked (using the
current method).
Once rollback is done, a new internal transaction is started, but you do not have to get a new instance of
TopiaTransaction.rollback in interface TopiaTransactionprotected void rollback0(boolean beginAfterRollback)
public boolean isClosed()
TopiaPersistenceContextisClosed in interface TopiaPersistenceContexttrue if the context is closed, false otherwisepublic void close()
TopiaPersistenceContextclose in interface Closeableclose in interface AutoCloseableclose in interface TopiaPersistenceContextprotected HibernateTopiaReplicationSupport getHibernateTopiaReplicationSupport()
public void replicate(TopiaEntity entity)
TopiaReplicationDestinationreplicate in interface TopiaReplicationDestinationentity - the remote entity to replicatepublic <T extends TopiaEntity> void replicateEntities(TopiaReplicationDestination topiaReplicationDestination, List<T> entities) throws IllegalArgumentException
TopiaReplicationSupportreplicateEntities in interface TopiaReplicationSupportT - type of entitytopiaReplicationDestination - the destination contextentities - the list of entities instance to replicateIllegalArgumentException - if one of the context is closed or if
trying to replicate within the same
databasepublic <T extends TopiaEntity> void replicateEntity(TopiaReplicationDestination topiaReplicationDestination, T entity) throws IllegalArgumentException
TopiaReplicationSupportreplicateEntity in interface TopiaReplicationSupportT - type of entitytopiaReplicationDestination - the destination contextentity - the entity instance to replicateIllegalArgumentException - if one of the context is closed or if
trying to replicate within the same
databasepublic void replicate(TopiaReplicationDestination topiaReplicationDestination, Object... entityAndCondition) throws IllegalArgumentException
TopiaReplicationSupportentityAndCondition parameter is empty,
all the database will be replicated
Note 2: The simple replication may not be sufficent. You may want
to replicate only a part of some entities : use the method TopiaReplicationSupport.replicateEntities(TopiaReplicationDestination, java.util.List).replicate in interface TopiaReplicationSupporttopiaReplicationDestination - the destination contextentityAndCondition - [key;value;...] parameter which key is the
entity class to replicate, and value the
"where" condition to use when querying entitiesIllegalArgumentException - if one of the context is closed or if
trying to replicate within the same
databaseCopyright © 2004–2020 Code Lutin. All rights reserved.