All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.tsl2.nano.replication.HibReplication Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show 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