org.hibernate.cfg.Configuration.setInterceptor()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中org.hibernate.cfg.Configuration.setInterceptor()方法的一些代码示例,展示了Configuration.setInterceptor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.setInterceptor()方法的具体详情如下:
包路径:org.hibernate.cfg.Configuration
类名称:Configuration
方法名:setInterceptor

Configuration.setInterceptor介绍

[英]Set the current Interceptor
[中]设置当前拦截器

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void configure(Configuration configuration) {
  super.configure( configuration );
  // applies the OnFlushDirtyInterceptor that is meant to track whether a Flush event fires
  // in situations where it ultimately shouldn't because null composites should equate an
  // instantiated component with all null properties.
  configuration.setInterceptor( i );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void configure(Configuration cfg) {
  cfg.setInterceptor( new ProxyInterceptor() );
}

代码示例来源:origin: org.hibernate/hibernate-annotations

@Override
public AnnotationConfiguration setInterceptor(Interceptor interceptor) {
  super.setInterceptor( interceptor );
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public AnnotationConfiguration setInterceptor(Interceptor interceptor) {
  super.setInterceptor( interceptor );
  return this;
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public Configuration setInterceptor(Interceptor interceptor) {
  super.setInterceptor(interceptor);
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

@Override
public AnnotationConfiguration setInterceptor(Interceptor interceptor) {
  super.setInterceptor( interceptor );
  return this;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb

public Ejb3Configuration setInterceptor(Interceptor interceptor) {
  cfg.setInterceptor( interceptor );
  return this;
}

代码示例来源:origin: uk.ac.ebi.intact/intact-core

/**
 * Either sets the given interceptor on the configuration or looks
 * it up from configuration if null.
 */
private void setInterceptor( Configuration configuration, Interceptor interceptor ) {
  String interceptorName = configuration.getProperty( INTERCEPTOR_CLASS );
  if ( interceptor == null && interceptorName != null ) {
    try {
      Class interceptorClass =
          AbstractHibernateDataConfig.class.getClassLoader().loadClass( interceptorName );
      interceptor = ( Interceptor ) interceptorClass.newInstance();
    } catch ( Exception ex ) {
      throw new RuntimeException( "Could not initialize interceptor: " + interceptorName, ex );
    }
  }
  if ( interceptor != null ) {
    configuration.setInterceptor( interceptor );
  } else {
    configuration.setInterceptor( EmptyInterceptor.INSTANCE );
  }
}

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate5-core

private void applyEntityInterceptor(Configuration config) {
  Object entityInterceptor = getConfigValue(sessionConfig, ENTITY_INTERCEPTOR, null);
  if (entityInterceptor instanceof Class) {
    config.setInterceptor((Interceptor) newInstanceOf((Class) entityInterceptor));
  } else if (entityInterceptor instanceof String) {
    config.setInterceptor((Interceptor) newInstanceOf((String) entityInterceptor));
  }
}

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate4-core

private void applyEntityInterceptor(Configuration config) {
  Object entityInterceptor = getConfigValue(sessionConfig, ENTITY_INTERCEPTOR, null);
  if (entityInterceptor instanceof Class) {
    config.setInterceptor((Interceptor) newInstanceOf((Class) entityInterceptor));
  } else if (entityInterceptor instanceof String) {
    config.setInterceptor((Interceptor) newInstanceOf((String) entityInterceptor));
  }
}

代码示例来源:origin: org.ow2.bonita/bonita-server

private static void addInterceptor(final Configuration configuration) {
 final String interceptorClassName = configuration.getProperty("bonita.hibernate.interceptor");
 if (interceptorClassName != null) {
  if (LOG.isLoggable(Level.INFO)) {
   LOG.info("Adding interceptor: " + interceptorClassName);
  }
  final Class<?> interceptorClass = ReflectUtil.loadClass(Thread.currentThread().getContextClassLoader(),
    interceptorClassName);
  final EmptyInterceptor interceptor = (EmptyInterceptor) ReflectUtil.newInstance(interceptorClass);
  configuration.setInterceptor(interceptor);
 }
}

代码示例来源:origin: com.weicoder/dao

config.setPhysicalNamingStrategy(ImprovedNamingStrategy.INSTANCE);
config.setInterceptor(EntityInterceptor.INSTANCE);

代码示例来源:origin: bonitasoft/bonita-engine

configuration.setInterceptor(new PostgresInterceptor());
  configuration.registerTypeOverride(new PostgresMaterializedBlobType());
  configuration.registerTypeOverride(new PostgresMaterializedClobType());
} else if (dialect.toLowerCase().contains("sqlserver")) {
  SQLServerInterceptor sqlServerInterceptor = new SQLServerInterceptor();
  configuration.setInterceptor(sqlServerInterceptor);
  configuration.registerTypeOverride(new XMLType());
  orderByBuilder = new SQLServerOrderByBuilder();
try {
  final Interceptor interceptor = (Interceptor) Class.forName(className).newInstance();
  configuration.setInterceptor(interceptor);
} catch (final ClassNotFoundException | IllegalAccessException | InstantiationException cnfe) {
  throw new SPersistenceException(cnfe);

代码示例来源:origin: bonitasoft/bonita-engine

configuration.setInterceptor(new PostgresInterceptor());
  configuration.registerTypeOverride(new PostgresMaterializedBlobType());
  configuration.registerTypeOverride(new PostgresMaterializedClobType());
} else if (dialect.toLowerCase().contains("sqlserver")) {
  SQLServerInterceptor sqlServerInterceptor = new SQLServerInterceptor();
  configuration.setInterceptor(sqlServerInterceptor);
  configuration.registerTypeOverride(new XMLType());
  orderByBuilder = new SQLServerOrderByBuilder();
try {
  final Interceptor interceptor = (Interceptor) Class.forName(className).newInstance();
  configuration.setInterceptor(interceptor);
} catch (final ClassNotFoundException | IllegalAccessException | InstantiationException cnfe) {
  throw new SPersistenceException(cnfe);

代码示例来源:origin: org.jboss.seam/jboss-seam

configuration.setInterceptor(new HibernateSecurityInterceptor(configuration.getInterceptor()));

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate

private SessionFactory getSessionFactory() {
  if (factory == null) {
    lock.lock();
    try {
      if (factory == null) {
        Configuration configuration = new Configuration();
        configuration.configure();
        configuration.setInterceptor(preInsertInterceptor);
        configuration.setProperty("hibernate.connection.url", hibernateProperties.getConnectionString());
        configuration.setProperty("hibernate.connection.username", hibernateProperties.getUser());
        configuration.setProperty("hibernate.connection.password", hibernateProperties.getPassword());
        // we have to setup the drivers to use depending on our jdbc connection string.  This is really
        // only to ensure that the correct drivers is picked up in Tomcat.  It has its own class loader rules
        // which mean this is a requirement.
        configuration.setProperty("hibernate.connection.driver_class", getDriverClass());
        ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
            configuration.getProperties()).build();
        factory = configuration.buildSessionFactory(serviceRegistry);
      }
    } finally {
      lock.unlock();
    }
  }
  return factory;
}

代码示例来源:origin: com.github.cafdataprocessing/boilerplate-api

private SessionFactory getSessionFactory() {
  if (factory == null) {
    lock.lock();
    try {
      if (factory == null) {
        Configuration configuration = new Configuration();
        configuration.configure();
        configuration.setInterceptor(preInsertInterceptor);
        configuration.setProperty("hibernate.connection.url", hibernateProperties.getConnectionString());
        configuration.setProperty("hibernate.connection.username", hibernateProperties.getUser());
        configuration.setProperty("hibernate.connection.password", hibernateProperties.getPassword());
        // we have to setup the drivers to use depending on our jdbc connection string.  This is really
        // only to ensure that the correct drivers is picked up in Tomcat.  It has its own class loader rules
        // which mean this is a requirement.
        configuration.setProperty("hibernate.connection.driver_class", getDriverClass());
        ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
            configuration.getProperties()).build();
        factory = configuration.buildSessionFactory(serviceRegistry);
      }
    } finally {
      lock.unlock();
    }
  }
  return factory;
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

private static void bindListeners() {
  configuration.setInterceptor(new NakedInterceptor());
  // add listeners required for updating Naked Objects
  final NakedEventListener eventListener = new NakedEventListener();
  final EventListeners listeners = configuration.getEventListeners();
  listeners.setInitializeCollectionEventListeners(new InitializeCollectionEventListener[] {
      new DefaultInitializeCollectionEventListener(), eventListener });
  listeners.setPreInsertEventListeners(new PreInsertEventListener[] { eventListener });
  listeners.setPostInsertEventListeners(new PostInsertEventListener[] { eventListener });
  listeners.setPreLoadEventListeners(new PreLoadEventListener[] { new DefaultPreLoadEventListener(), eventListener });
  listeners.setLoadEventListeners(new LoadEventListener[] { new NakedLoadEventListener() });
  listeners.setPostLoadEventListeners(new PostLoadEventListener[] { new DefaultPostLoadEventListener(), eventListener });
  listeners.setPreUpdateEventListeners(new PreUpdateEventListener[] { eventListener });
  listeners.setPostUpdateEventListeners(new PostUpdateEventListener[] { eventListener });
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

config.setInterceptor(InterceptorV5Adapter.adapt(getInterceptor()));

代码示例来源:origin: vladmihalcea/high-performance-java-persistence

configuration.setInterceptor(interceptor);

相关文章

Configuration类方法