Class HibernateTopiaReplicationSupport
java.lang.Object
org.nuiton.topia.persistence.internal.support.HibernateTopiaReplicationSupport
- All Implemented Interfaces:
TopiaReplicationSupport,TopiaReplicationDestination
public class HibernateTopiaReplicationSupport
extends Object
implements TopiaReplicationSupport, TopiaReplicationDestination
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHibernateTopiaReplicationSupport(TopiaHibernateSupport topiaHibernateSupport) -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]buildQueries(Object... entityAndCondition) Build the list of queries from the given parameterentityAndCondition.voidreplicate(TopiaEntity entity) Must replicate given entity in current databasevoidreplicate(TopiaReplicationDestination topiaReplicationDestination, Object... entityAndCondition) Makes a replication of some entities from this context to the given context without any entity modification.protected voidreplicate0(TopiaReplicationDestination topiaReplicationDestination, Object... entities) <T extends TopiaEntity>
voidreplicateEntities(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>
voidreplicateEntity(TopiaReplicationDestination topiaReplicationDestination, T entity) Replicate a given entity from this context to the given context.
-
Field Details
-
topiaHibernateSupport
-
-
Constructor Details
-
HibernateTopiaReplicationSupport
-
-
Method Details
-
replicate
public void replicate(TopiaReplicationDestination topiaReplicationDestination, Object... entityAndCondition) throws IllegalArgumentException Description copied from interface:TopiaReplicationSupportMakes a replication of some entities from this context to the given context without any entity modification. Note: If theentityAndConditionparameter 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 methodTopiaReplicationSupport.replicateEntities(TopiaReplicationDestination, java.util.List).- Specified by:
replicatein interfaceTopiaReplicationSupport- Parameters:
topiaReplicationDestination- the destination contextentityAndCondition- [key;value;...] parameter which key is the entity class to replicate, and value the "where" condition to use when querying entities- Throws:
IllegalArgumentException- if one of the context is closed or if trying to replicate within the same database
-
replicateEntity
public <T extends TopiaEntity> void replicateEntity(TopiaReplicationDestination topiaReplicationDestination, T entity) throws IllegalArgumentException Description copied from interface:TopiaReplicationSupportReplicate a given entity from this context to the given context.- Specified by:
replicateEntityin interfaceTopiaReplicationSupport- Type Parameters:
T- type of entity- Parameters:
topiaReplicationDestination- the destination contextentity- the entity instance to replicate- Throws:
IllegalArgumentException- if one of the context is closed or if trying to replicate within the same database
-
replicateEntities
public <T extends TopiaEntity> void replicateEntities(TopiaReplicationDestination topiaReplicationDestination, List<T> entities) throws IllegalArgumentException Description copied from interface:TopiaReplicationSupportMakes a replication of some entities from this context to the given context without any entity modification.- Specified by:
replicateEntitiesin interfaceTopiaReplicationSupport- Type Parameters:
T- type of entity- Parameters:
topiaReplicationDestination- the destination contextentities- the list of entities instance to replicate- Throws:
IllegalArgumentException- if one of the context is closed or if trying to replicate within the same database
-
replicate0
protected void replicate0(TopiaReplicationDestination topiaReplicationDestination, Object... entities) -
buildQueries
protected String[] buildQueries(Object... entityAndCondition) throws TopiaException, IllegalArgumentException Build the list of queries from the given parameterentityAndCondition. If no parameter is given, then build the queries for all entities is db, with no condition.- Parameters:
entityAndCondition- the list of tuples (Class,String)- Returns:
- the list of queries.
- Throws:
TopiaException- if any pb of db while getting entities classes.IllegalArgumentException- if any pb with the given parameter (mainly ClassCastException).
-
replicate
Description copied from interface:TopiaReplicationDestinationMust replicate given entity in current database- Specified by:
replicatein interfaceTopiaReplicationDestination- Parameters:
entity- the remote entity to replicate
-