de.tsl2.nano.replication.HibReplication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.replication Show documentation
Show all versions of tsl2.nano.replication Show documentation
Provides Database/XML Replication through JPA
The newest version!
package de.tsl2.nano.replication;
import javax.persistence.EntityManager;
import org.hibernate.ReplicationMode;
import org.hibernate.Session;
/**
* calls the replicat() method of a hibernate session. The given entity should be detached from source entitymanager/session
* WARNING: having src + dest EntityManagers in one Java-VM does not work! tried src.clear(), src.close() and further more..
* @param
* @author Tom, Thomas Schneider
* @version $Revision$
*/
public class HibReplication {
EntityManager destEM;
public HibReplication(EntityManager destEM) {
this.destEM = destEM;
}
public void strategyHibReplicate(T entity) {
Session hibernateSession = destEM.unwrap(Session.class);
hibernateSession.replicate(entity, ReplicationMode.OVERWRITE);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy