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


Java EmptyInterceptor类代码示例

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


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

示例1: configureRunsBeforeSessionFactoryCreation

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
@Test
public void configureRunsBeforeSessionFactoryCreation(){
    final SessionFactoryFactory customFactory = new SessionFactoryFactory() {
        @Override
        protected void configure(final Configuration configuration, final ServiceRegistry registry) {
            super.configure(configuration, registry);
            configuration.setInterceptor(EmptyInterceptor.INSTANCE);
        }
    };
    this.sessionFactory = customFactory.build(this.bundle,
                                         this.environment,
                                         this.config,
                                         ImmutableList.<Class<?>>of(Person.class),
                                         RemoteCredentialHibernateBundle.DEFAULT_NAME);

    assertThat(this.sessionFactory.getSessionFactoryOptions().getInterceptor()).isSameAs(EmptyInterceptor.INSTANCE);
}
 
开发者ID:mtakaki,项目名称:CredentialStorageService-dw-hibernate,代码行数:18,代码来源:SessionFactoryFactoryTest.java

示例2: reset

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
protected void reset() {
		classes = new HashMap();
		imports = new HashMap();
		collections = new HashMap();
		tables = new TreeMap();
		namedQueries = new HashMap();
		namedSqlQueries = new HashMap();
		sqlResultSetMappings = new HashMap();
		xmlHelper = new XMLHelper();
		typeDefs = new HashMap();
		propertyReferences = new ArrayList();
		secondPasses = new ArrayList();
		interceptor = EmptyInterceptor.INSTANCE;
		properties = Environment.getProperties();
		entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
		eventListeners = new EventListeners();
		filterDefinitions = new HashMap();
//		extendsQueue = new ArrayList();
		extendsQueue = new HashMap();
		auxiliaryDatabaseObjects = new ArrayList();
		tableNameBinding = new HashMap();
		columnNameBindingPerTable = new HashMap();
		namingStrategy = DefaultNamingStrategy.INSTANCE;
		sqlFunctions = new HashMap();
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:Configuration.java

示例3: interceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
@Override
protected Interceptor interceptor() {
    return new EmptyInterceptor() {
        private Long startNanos;

        @Override
        public void preFlush(Iterator entities) {
            startNanos = System.nanoTime();
        }

        @Override
        public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
            if (enableMetrics) {
                timer.update(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
            }
            return false;
        }
    };
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:20,代码来源:BytecodeEnhancementDirtyCheckingPerformanceTest.java

示例4: testPropertyIntercept2

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
/**
 * Test case from HHH-1921.  Here the interceptor resets the
 * current-state to the same thing as the current db state; this
 * causes EntityPersister.findDirty() to return no dirty properties.
 */
public void testPropertyIntercept2() {
	Session s = openSession();
	Transaction t = s.beginTransaction();
	User u = new User("Josh", "test");
	s.persist( u );
	t.commit();
	s.close();

	s = openSession(
			new EmptyInterceptor() {
				public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
					currentState[0] = "test";
					return true;
				}
			}
	);
	t = s.beginTransaction();
	u = ( User ) s.get( User.class, u.getName() );
	u.setPassword( "nottest" );
	t.commit();
	s.close();

	s = openSession();
	t = s.beginTransaction();
	u = (User) s.get(User.class, "Josh");
	assertEquals("test", u.getPassword());
	s.delete(u);
	t.commit();
	s.close();

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:InterceptorTest.java

示例5: testComponentInterceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
public void testComponentInterceptor() {
	final int checkPerm = 500;
	final String checkComment = "generated from interceptor";

	Session s = openSession(
			new EmptyInterceptor() {
				public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
					if ( state[0] == null ) {
						Image.Details detail = new Image.Details();
						detail.setPerm1( checkPerm );
						detail.setComment( checkComment );
						state[0] = detail;
					}
					return true;
				}
			}
	);
	s.beginTransaction();
	Image i = new Image();
	i.setName( "compincomp" );
	i = ( Image ) s.merge( i );
	assertNotNull( i.getDetails() );
	assertEquals( checkPerm, i.getDetails().getPerm1() );
	assertEquals( checkComment, i.getDetails().getComment() );
	s.getTransaction().commit();
	s.close();

	s = openSession();
	s.beginTransaction();
	i = ( Image ) s.get( Image.class, i.getId() );
	assertNotNull( i.getDetails() );
	assertEquals( checkPerm, i.getDetails().getPerm1() );
	assertEquals( checkComment, i.getDetails().getComment() );
	s.delete( i );
	s.getTransaction().commit();
	s.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:InterceptorTest.java

示例6: interceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
@Override
protected Interceptor interceptor() {
    return new EmptyInterceptor() {
        @Override
        public void beforeTransactionCompletion(Transaction tx) {
            if(applyInterceptor.get()) {
                tx.rollback();
            }
        }
    };
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:12,代码来源:ReadWriteCacheConcurrencyStrategyWithLockTimeoutTest.java

示例7: getSession

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
private static Session getSession() {
    // we need a session that bypasses security, so override the security interceptor here
    return hibernateHelper.getSessionFactory().openSession(new EmptyInterceptor() {

        private static final long serialVersionUID = 1L;
    });
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:8,代码来源:HibernateIntegrationTestCleanUpUtility.java

示例8: reset

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
protected void reset() {
		metadataSourceQueue = new MetadataSourceQueue();
		createReflectionManager();

		classes = new HashMap<String,PersistentClass>();
		imports = new HashMap<String,String>();
		collections = new HashMap<String,Collection>();
		tables = new TreeMap<String,Table>();

		namedQueries = new HashMap<String,NamedQueryDefinition>();
		namedSqlQueries = new HashMap<String,NamedSQLQueryDefinition>();
		sqlResultSetMappings = new HashMap<String, ResultSetMappingDefinition>();
		namedEntityGraphMap = new HashMap<String, NamedEntityGraphDefinition>();
		namedProcedureCallMap = new HashMap<String, NamedProcedureCallDefinition>(  );
		typeDefs = new HashMap<String,TypeDef>();
		filterDefinitions = new HashMap<String, FilterDefinition>();
		fetchProfiles = new HashMap<String, FetchProfile>();
		auxiliaryDatabaseObjects = new ArrayList<AuxiliaryDatabaseObject>();

		tableNameBinding = new HashMap();
		columnNameBindingPerTable = new HashMap();

		secondPasses = new ArrayList<SecondPass>();
		propertyReferences = new ArrayList<Mappings.PropertyReference>();
		extendsQueue = new HashMap<ExtendsQueueEntry, String>();

		xmlHelper = new XMLHelper();
		interceptor = EmptyInterceptor.INSTANCE;
		properties = Environment.getProperties();
		entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;

		sqlFunctions = new HashMap<String, SQLFunction>();

		entityTuplizerFactory = new EntityTuplizerFactory();
//		componentTuplizerFactory = new ComponentTuplizerFactory();

		identifierGeneratorFactory = new DefaultIdentifierGeneratorFactory();

		mappedSuperClasses = new HashMap<Class<?>, MappedSuperclass>();

		metadataSourcePrecedence = Collections.emptyList();

		namedGenerators = new HashMap<String, IdGenerator>();
		joins = new HashMap<String, Map<String, Join>>();
		classTypes = new HashMap<String, AnnotatedClassType>();
		generatorTables = new HashMap<String, Properties>();
		defaultNamedQueryNames = new HashSet<String>();
		defaultNamedNativeQueryNames = new HashSet<String>();
		defaultSqlResultSetMappingNames = new HashSet<String>();
		defaultNamedProcedure =  new HashSet<String>(  );
		defaultNamedGenerators = new HashSet<String>();
		uniqueConstraintHoldersByTable = new HashMap<Table, List<UniqueConstraintHolder>>();
		jpaIndexHoldersByTable = new HashMap<Table,List<JPAIndexHolder>>(  );
		mappedByResolver = new HashMap<String, String>();
		propertyRefResolver = new HashMap<String, String>();
		caches = new ArrayList<CacheHolder>();
		namingStrategyDelegator = LegacyNamingStrategyDelegator.DEFAULT_INSTANCE;
		setEntityResolver( new EJB3DTDEntityResolver() );
		anyMetaDefs = new HashMap<String, AnyMetaDef>();
		propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>();
		propertiesAnnotatedWithIdAndToOne = new HashMap<XClass, Map<String, PropertyData>>();
		specjProprietarySyntaxEnabled = System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null;
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:64,代码来源:Configuration.java

示例9: noInterceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
@Override
public SessionBuilder noInterceptor() {
	this.interceptor = EmptyInterceptor.INSTANCE;
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:SessionFactoryImpl.java

示例10: getInterceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
@Override
public Interceptor getInterceptor() {
	return EmptyInterceptor.INSTANCE;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:StatelessSessionImpl.java

示例11: StatelessSessionImpl

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
StatelessSessionImpl(Connection connection, SessionFactoryImpl factory) {
	super( factory );
	this.jdbcContext = new JDBCContext( this, connection, EmptyInterceptor.INSTANCE );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:5,代码来源:StatelessSessionImpl.java

示例12: getInterceptor

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
public Interceptor getInterceptor() {
	return EmptyInterceptor.INSTANCE;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:4,代码来源:StatelessSessionImpl.java

示例13: getSession

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
public static Session getSession(EmptyInterceptor emptyinterceptor)
		throws Exception {
	Session session = getSession();
	declaredField.set(session, emptyinterceptor);
	return session;
}
 
开发者ID:316181444,项目名称:Hxms,代码行数:7,代码来源:DatabaseConnection.java

示例14: verifyDump

import org.hibernate.EmptyInterceptor; //导入依赖的package包/类
/**
 * Verify the imported dump.
 * @return Number of checked objects. This number is negative if any error occurs (at least one object wasn't imported successfully).
 */
public int verifyDump(final XStreamSavingConverter xstreamSavingConverter)
{
  final SessionFactory sessionFactory = hibernate.getSessionFactory();
  Session session = null;
  boolean hasError = false;
  try {
    session = sessionFactory.openSession(EmptyInterceptor.INSTANCE);
    session.setDefaultReadOnly(true);
    int counter = 0;
    for (final Map.Entry<Class< ? >, List<Object>> entry : xstreamSavingConverter.getAllObjects().entrySet()) {
      final List<Object> objects = entry.getValue();
      final Class< ? > entityClass = entry.getKey();
      if (objects == null) {
        continue;
      }
      for (final Object obj : objects) {
        if (HibernateUtils.isEntity(obj.getClass()) == false) {
          continue;
        }
        final Serializable id = HibernateUtils.getIdentifier(obj);
        if (id == null) {
          // Can't compare this object without identifier.
          continue;
        }
        // log.info("Testing object: " + obj);
        final Object databaseObject = session.get(entityClass, id, LockOptions.READ);
        Hibernate.initialize(databaseObject);
        final boolean equals = equals(obj, databaseObject, true);
        if (equals == false) {
          log.error("Object not sucessfully imported! xml object=[" + obj + "], data base=[" + databaseObject + "]");
          hasError = true;
        }
        ++counter;
      }
    }
    for (final HistoryEntry historyEntry : xstreamSavingConverter.getHistoryEntries()) {
      final Class< ? > type = xstreamSavingConverter.getClassFromHistoryName(historyEntry.getClassName());
      final Object o = type != null ? session.get(type, historyEntry.getEntityId()) : null;
      if (o == null) {
        log.warn("A corrupted history entry found (entity of class '"
            + historyEntry.getClassName()
            + "' with id "
            + historyEntry.getEntityId()
            + " not found: "
            + historyEntry
            + ". This doesn't affect the functioning of ProjectForge, this may result in orphaned history entries.");
        hasError = true;
      }
      ++counter;
    }
    if (hasError == true) {
      log.fatal("*********** A inconsistency in the import was found! This may result in a data loss or corrupted data! Please retry the import. "
          + counter
          + " entries checked.");
      return -counter;
    }
    log.info("Data-base import successfully verified: " + counter + " entries checked.");
    return counter;
  } finally {
    if (session != null) {
      session.close();
    }
  }
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:69,代码来源:XmlDump.java


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