Example usage for org.hibernate.cfg AvailableSettings MULTI_TENANT_IDENTIFIER_RESOLVER

List of usage examples for org.hibernate.cfg AvailableSettings MULTI_TENANT_IDENTIFIER_RESOLVER

Introduction

In this page you can find the example usage for org.hibernate.cfg AvailableSettings MULTI_TENANT_IDENTIFIER_RESOLVER.

Prototype

String MULTI_TENANT_IDENTIFIER_RESOLVER

To view the source code for org.hibernate.cfg AvailableSettings MULTI_TENANT_IDENTIFIER_RESOLVER.

Click Source Link

Document

Names a org.hibernate.context.spi.CurrentTenantIdentifierResolver implementation to use.

Usage

From source file:com.baomidou.hibernateplus.HibernateSpringSessionFactoryBuilder.java

License:Apache License

/**
 * Overridden to reliably pass a {@link CurrentTenantIdentifierResolver} to the SessionFactory.
 *
 * @see AvailableSettings#MULTI_TENANT_IDENTIFIER_RESOLVER
 * @since 4.3.2/*www.ja  v  a2 s .  c om*/
 */
@Override
public void setCurrentTenantIdentifierResolver(
        CurrentTenantIdentifierResolver currentTenantIdentifierResolver) {
    getProperties().put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver);
    super.setCurrentTenantIdentifierResolver(currentTenantIdentifierResolver);
}

From source file:com.github.javarch.persistence.orm.hibernate.conf.HibernatePropertiesConfig.java

License:Apache License

/**
 * Retorna um objeto Properties com todas as configuraes de propriedades que devem
 * ser passadas ao {@link SessionFactory}. As propriedades so definidas no arquivo
 * hibernate.properties que deve estar presente no raiz do classpath.
 * //from   w  w w.  j  a  v a2  s  .c  o m
 * @return Properties do Hibernate.
 */
@Bean
public Properties hibernateProperties() {

    Properties props = new Properties();

    props.put(AvailableSettings.DIALECT, env.getRequiredProperty(AvailableSettings.DIALECT));

    if (env.acceptsProfiles(Profiles.TEST)) {
        props.put(AvailableSettings.HBM2DDL_AUTO, env.getProperty(AvailableSettings.HBM2DDL_AUTO, "update"));
    }

    if (env.acceptsProfiles(Profiles.MULT_TENANT)) {
        if (log.isDebugEnabled()) {
            log.debug("Profile Multi Tenancy ativado! Realizando configurao...");
        }
        if (currentIdentifierResolver == null || env.acceptsProfiles(Profiles.PRODUCTION)) {
            throw new DatabaseConfigurationException(
                    "No foi encontrado nenhum objeto CurrentIdentifierResolver.");
        }
        props.put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentIdentifierResolver);
        props.put(AvailableSettings.DATASOURCE, env.getRequiredProperty(AvailableSettings.DATASOURCE));
        props.put(AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider);
        props.put(AvailableSettings.MULTI_TENANT, env.getRequiredProperty(AvailableSettings.MULTI_TENANT));
    } else {

        props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, true);
        props.put(AvailableSettings.USE_QUERY_CACHE, true);
        props.put(AvailableSettings.CACHE_REGION_FACTORY, "org.hibernate.cache.ehcache.EhCacheRegionFactory");
    }

    if (env.acceptsProfiles(Profiles.ENVERS)) {
        props.put("org.hibernate.envers.versionsTableSuffix", "_audit");
        props.put("org.hibernate.envers.revisionFieldName", "revision");
        props.put("org.hibernate.envers.default_schema", "audit");
    }

    return props;
}

From source file:org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.java

License:Apache License

/**
 * Set a Hibernate 4.1/4.2/4.3 {@code CurrentTenantIdentifierResolver} to be passed
 * on to the SessionFactory: as an instance, a Class, or a String class name.
 * @since 4.0/*from   w w w  .ja  v  a  2s  . c om*/
 * @see AvailableSettings#MULTI_TENANT_IDENTIFIER_RESOLVER
 */
public LocalSessionFactoryBuilder setCurrentTenantIdentifierResolver(Object currentTenantIdentifierResolver) {
    getProperties().put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver);
    return this;
}