Example usage for org.hibernate Session replicate

List of usage examples for org.hibernate Session replicate

Introduction

In this page you can find the example usage for org.hibernate Session replicate.

Prototype

void replicate(String entityName, Object object, ReplicationMode replicationMode);

Source Link

Document

Persist the state of the given detached instance, reusing the current identifier value.

Usage

From source file:com.jdon.persistence.hibernate.HibernateTemplate.java

License:Apache License

public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws Exception {

    doHibernate(new HibernateCallback() {
        public Object execute(Session session) throws HibernateException {
            session.replicate(entityName, entity, replicationMode);
            return null;
        }//from w  w w . j a v  a2s. co  m
    });
}

From source file:org.opengoss.dao.hibernate.DataAccessor.java

License:Apache License

public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DaoException {

    execute(new IAccessorCallback() {
        public Object call(Session session) throws HibernateException {
            session.replicate(entityName, entity, replicationMode);
            return null;
        }//from  ww w.  j  a v  a 2s  . c om
    });
}

From source file:org.springframework.orm.hibernate3.HibernateTemplate.java

License:Apache License

@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override//from  w  w  w  . j  av a  2 s .c  o m
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}

From source file:org.springframework.orm.hibernate3.StatelessHibernateTemplate.java

License:Apache License

public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }/*from  w ww  . ja  v a2 s .  c o m*/
    }, true);
}

From source file:ro.cs.om.model.dao.impl.DaoRoleImpl.java

License:Open Source License

/**
 * same thing as addDefaultRoles(Integer organisationId, Integer moduleId) but using the same session
 *//*from  w  w w . j a v a2s . c  o m*/
public void addDefaultRoles(Integer organisationId, Integer moduleId, Session session) {
    logger.debug("Add default roles DAO IMPL - START- ");
    List<RoleWeb> roles = getDefaultRolesByModule(moduleId);
    for (RoleWeb role : roles) {
        role.setOrganisationId(organisationId);
        role.setModuleId(moduleId);
        Localization description = new Localization();
        description.setLocalizationId(0);
        description.setEn(role.getDescription().getEn());
        description.setRo(role.getDescription().getRo());
        logger.debug("description role = " + role.getDescription());
        session.save(IModelConstant.localizationEntity, description);
        role.setDescription(description);
        //session.evict(IModelConstant.roleWebEntity);
        //logger.debug("After evict " + role);
        role.setRoleId(0);
        logger.debug("Role " + role);
        session.replicate(IModelConstant.roleWebEntity, role, ReplicationMode.IGNORE);
        logger.debug("fter save " + role);
    }
    logger.debug("Add default roles DAO IMPL - END- ");
}