当前位置: 首页>>代码示例>>Java>>正文


Java ReplicationMode类代码示例

本文整理汇总了Java中org.hibernate.ReplicationMode的典型用法代码示例。如果您正苦于以下问题:Java ReplicationMode类的具体用法?Java ReplicationMode怎么用?Java ReplicationMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReplicationMode类属于org.hibernate包,在下文中一共展示了ReplicationMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ReplicateEvent

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:ReplicateEvent.java

示例2: cascadeAfterReplicate

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DefaultReplicateEventListener.java

示例3: execute

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:18,代码来源:ReplicateObjectsCommand.java

示例4: addDefaultRoles

import org.hibernate.ReplicationMode; //导入依赖的package包/类
/**
 * 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- ");
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:26,代码来源:DaoRoleImpl.java

示例5: replicate

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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;
		}
	});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:HibernateTemplate.java

示例6: cascade

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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 );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:CascadingActions.java

示例7: performReplication

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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 );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:DefaultReplicateEventListener.java

示例8: importData

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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);
			}
		}
	}	
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:37,代码来源:DefaultPersistManager.java

示例9: testReplicate

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:HibernateTemplateTests.java

示例10: testReplicateWithEntityName

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:HibernateTemplateTests.java

示例11: testReplicate

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:HibernateTemplateTests.java

示例12: testReplicateWithEntityName

import org.hibernate.ReplicationMode; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:HibernateTemplateTests.java

示例13: cascade

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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 );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:CascadingAction.java

示例14: performReplication

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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 );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:DefaultReplicateEventListener.java

示例15: cascadeAfterReplicate

import org.hibernate.ReplicationMode; //导入依赖的package包/类
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();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:15,代码来源:DefaultReplicateEventListener.java


注:本文中的org.hibernate.ReplicationMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。