Java 类org.hibernate.ReplicationMode 实例源码

项目:lams    文件:ReplicateEvent.java   
public ReplicateEvent(String entityName, Object object, ReplicationMode replicationMode, EventSource source) {
    super(source);
    this.entityName = entityName;

    if ( object == null ) {
        throw new IllegalArgumentException(
                "attempt to create replication strategy with null entity"
        );
    }
    if ( replicationMode == null ) {
        throw new IllegalArgumentException(
                "attempt to create replication strategy with null replication mode"
        );
    }

    this.object = object;
    this.replicationMode = replicationMode;
}
项目:lams    文件:DefaultReplicateEventListener.java   
private void cascadeAfterReplicate(
        Object entity,
        EntityPersister persister,
        ReplicationMode replicationMode,
        EventSource source) {
    source.getPersistenceContext().incrementCascadeLevel();
    try {
        new Cascade( CascadingActions.REPLICATE, CascadePoint.AFTER_UPDATE, source ).cascade(
                persister,
                entity,
                replicationMode
        );
    }
    finally {
        source.getPersistenceContext().decrementCascadeLevel();
    }
}
项目:bisis-v4    文件:ReplicateObjectsCommand.java   
@Override
public void execute() {
    Transaction tx = session.beginTransaction();
    try{
        for (Object item : list){
            session.replicate(item, ReplicationMode.IGNORE);
        }
        tx.commit();
        success = true;
        log.info("saving objects successfully: " + list.get(0).getClass());
    } catch (HibernateException e) {
        tx.rollback();
        log.error("saving objects failed: " + list.get(0).getClass());
        log.error(e);
        message = e.getMessage();
    }
}
项目:cacheonix-core    文件:ReplicateEvent.java   
public ReplicateEvent(String entityName, Object object, ReplicationMode replicationMode, EventSource source) {
    super(source);
    this.entityName = entityName;

    if ( object == null ) {
        throw new IllegalArgumentException(
                "attempt to create replication strategy with null entity"
        );
    }
    if ( replicationMode == null ) {
        throw new IllegalArgumentException(
                "attempt to create replication strategy with null replication mode"
        );
    }

    this.object = object;
    this.replicationMode = replicationMode;
}
项目:termitaria    文件:DaoRoleImpl.java   
/**
 * same thing as addDefaultRoles(Integer organisationId, Integer moduleId) but using the same session
 */
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- ");
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:lams    文件:CascadingActions.java   
@Override
public void cascade(
        EventSource session,
        Object child,
        String entityName,
        Object anything,
        boolean isCascadeDeleteEnabled)
        throws HibernateException {
    LOG.tracev( "Cascading to replicate: {0}", entityName );
    session.replicate( entityName, child, (ReplicationMode) anything );
}
项目:lams    文件:DefaultReplicateEventListener.java   
private void performReplication(
        Object entity,
        Serializable id,
        Object version,
        EntityPersister persister,
        ReplicationMode replicationMode,
        EventSource source) throws HibernateException {

    if ( LOG.isTraceEnabled() ) {
        LOG.tracev( "Replicating changes to {0}", MessageHelper.infoString( persister, id, source.getFactory() ) );
    }

    new OnReplicateVisitor( source, id, entity, true ).process( entity, persister );

    source.getPersistenceContext().addEntity(
            entity,
            ( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
            null,
            source.generateEntityKey( id, persister ),
            version,
            LockMode.NONE,
            true,
            persister,
            true,
            false
    );

    cascadeAfterReplicate( entity, persister, replicationMode, source );
}
项目:gitplex-mit    文件:DefaultPersistManager.java   
@Sessional
@Override
public void importData(Metadata metadata, File dataDir) {
    Session session = dao.getSession();
    List<Class<?>> entityTypes = getEntityTypes(sessionFactory);
    Collections.reverse(entityTypes);
    for (Class<?> entityType: entityTypes) {
        File[] dataFiles = dataDir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.startsWith(entityType.getSimpleName() + "s.xml");
            }

        });
        for (File file: dataFiles) {
            try {
                logger.info("Importing from data file '" + file.getName() + "'...");
                session.beginTransaction();
                VersionedDocument dom = VersionedDocument.fromFile(file);

                for (Element element: dom.getRootElement().elements()) {
                    element.detach();
                    AbstractEntity entity = (AbstractEntity) new VersionedDocument(DocumentHelper.createDocument(element)).toBean();
                    session.replicate(entity, ReplicationMode.EXCEPTION);
                }
                session.flush();
                session.clear();
                session.getTransaction().commit();
            } catch (Throwable e) {
                session.getTransaction().rollback();
                throw Throwables.propagate(e);
            }
        }
    }   
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplateTests.java   
@Test
public void testReplicate() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();
    verify(session).close();
}
项目:spring4-understanding    文件:HibernateTemplateTests.java   
@Test
public void testReplicateWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();
    verify(session).close();
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplate.java   
@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:spring4-understanding    文件:HibernateTemplateTests.java   
@Test
public void testReplicate()  {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate(tb, ReplicationMode.LATEST_VERSION);
}
项目:spring4-understanding    文件:HibernateTemplateTests.java   
@Test
public void testReplicateWithEntityName()  {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
}
项目:cacheonix-core    文件:CascadingAction.java   
public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
throws HibernateException {
    if ( log.isTraceEnabled() ) {
        log.trace( "cascading to replicate: " + entityName );
    }
    session.replicate( entityName, child, (ReplicationMode) anything );
}
项目:cacheonix-core    文件:DefaultReplicateEventListener.java   
private void performReplication(
        Object entity,
        Serializable id,
        Object version,
        EntityPersister persister,
        ReplicationMode replicationMode,
        EventSource source) throws HibernateException {

    if ( log.isTraceEnabled() ) {
        log.trace(
                "replicating changes to " +
                        MessageHelper.infoString( persister, id, source.getFactory() )
        );
    }

    new OnReplicateVisitor( source, id, entity, true ).process( entity, persister );

    source.getPersistenceContext().addEntity(
            entity,
            Status.MANAGED,
            null,
            new EntityKey( id, persister, source.getEntityMode() ),
            version,
            LockMode.NONE,
            true,
            persister,
            true,
            false
    );

    cascadeAfterReplicate( entity, persister, replicationMode, source );
}
项目:cacheonix-core    文件:DefaultReplicateEventListener.java   
private void cascadeAfterReplicate(
        Object entity,
        EntityPersister persister,
        ReplicationMode replicationMode,
        EventSource source) {
    source.getPersistenceContext().incrementCascadeLevel();
    try {
        new Cascade( CascadingAction.REPLICATE, Cascade.AFTER_UPDATE, source )
                .cascade( persister, entity, replicationMode );
    }
    finally {
        source.getPersistenceContext().decrementCascadeLevel();
    }
}
项目:cacheonix-core    文件:ParentChildTest.java   
public void testReplicate() throws Exception {
    Session s = openSession();
    Container baz = new Container();
    Contained f = new Contained();
    List list = new ArrayList();
    list.add(baz);
    f.setBag(list);
    List list2 = new ArrayList();
    list2.add(f);
    baz.setBag(list2);
    s.save(f);
    s.save(baz);
    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();
    s.replicate(baz, ReplicationMode.OVERWRITE);

    // HHH-2378
    SessionImpl x = (SessionImpl)s;
    EntityEntry entry = x.getPersistenceContext().getEntry( baz );
    assertNull(entry.getVersion());

    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();
    s.replicate(baz, ReplicationMode.IGNORE);
    s.flush();
    s.connection().commit();
    s.close();
    s = openSession();
    s.delete(baz);
    s.delete(f);
    s.flush();
    s.connection().commit();
    s.close();
}
项目:hql-builder    文件:HibernateTemplate.java   
/**
 * Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value.
 * 
 * @param entity the persistent object to replicate
 * @param replicationMode the Hibernate ReplicationMode
 * @throws DataAccessException in case of Hibernate errors
 * @see org.hibernate.Session#replicate(Object, org.hibernate.ReplicationMode)
 */
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode) throws DataAccessException {
    executeWithNativeSession(session -> {
        checkWriteOperationAllowed(session);
        session.replicate(entity, replicationMode);
        return null;
    });
}
项目:hql-builder    文件:HibernateTemplate.java   
/**
 * Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value.
 * 
 * @param entity the persistent object to replicate
 * @param replicationMode the Hibernate ReplicationMode
 * @throws DataAccessException in case of Hibernate errors
 * @see org.hibernate.Session#replicate(Object, org.hibernate.ReplicationMode)
 */
@Override
public void replicate(final Object entity, final ReplicationMode replicationMode) throws DataAccessException {
    executeWithNativeSession(session -> {
        checkWriteOperationAllowed(session);
        session.replicate(entity, replicationMode);
        return null;
    });
}
项目:class-guard    文件:HibernateTemplate.java   
public void replicate(final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entity, replicationMode);
            return null;
        }
    });
}
项目:class-guard    文件:HibernateTemplate.java   
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
        throws DataAccessException {

    executeWithNativeSession(new HibernateCallback<Object>() {
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.replicate(entityName, entity, replicationMode);
            return null;
        }
    });
}
项目:class-guard    文件:HibernateTemplateTests.java   
@Test
public void testReplicate() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate(tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();
    verify(session).close();
}
项目:class-guard    文件:HibernateTemplateTests.java   
@Test
public void testReplicateWithEntityName() throws HibernateException {
    TestBean tb = new TestBean();
    given(session.getFlushMode()).willReturn(FlushMode.AUTO);
    hibernateTemplate.replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).replicate("myEntity", tb, ReplicationMode.LATEST_VERSION);
    verify(session).flush();
    verify(session).close();
}
项目:lams    文件:SessionDelegatorBaseImpl.java   
@Override
public void replicate(Object object, ReplicationMode replicationMode) {
    session.replicate( object, replicationMode );
}
项目:lams    文件:SessionDelegatorBaseImpl.java   
@Override
public void replicate(String entityName, Object object, ReplicationMode replicationMode) {
    session.replicate( entityName, object, replicationMode );
}
项目:lams    文件:SessionImpl.java   
@Override
public void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException {
    fireReplicate( new ReplicateEvent( obj, replicationMode, this ) );
}
项目:lams    文件:SessionImpl.java   
@Override
public void replicate(String entityName, Object obj, ReplicationMode replicationMode)
throws HibernateException {
    fireReplicate( new ReplicateEvent( entityName, obj, replicationMode, this ) );
}
项目:lams    文件:ReplicateEvent.java   
public ReplicateEvent(Object object, ReplicationMode replicationMode, EventSource source) {
    this(null, object, replicationMode, source);
}
项目:lams    文件:ReplicateEvent.java   
public ReplicationMode getReplicationMode() {
    return replicationMode;
}
项目:lams    文件:ReplicateEvent.java   
public void setReplicationMode(ReplicationMode replicationMode) {
    this.replicationMode = replicationMode;
}
项目:tinyshop8    文件:GoodsTypeDAOTest.java   
@Override
public void replicate(Object o, ReplicationMode replicationMode) throws DataAccessException
{

}