本文整理汇总了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;
}
示例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();
}
}
示例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();
}
}
示例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- ");
}
示例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;
}
});
}
示例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 );
}
示例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 );
}
示例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);
}
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}
示例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 );
}
示例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();
}
}