Search in sources :

Example 1 with MutableIdentifierGeneratorFactory

use of org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory in project hibernate-orm by hibernate.

the class EntityManagerFactoryBuilderImpl method configure.

private void configure(StandardServiceRegistry ssr, MergedSettings mergedSettings) {
    final StrategySelector strategySelector = ssr.getService(StrategySelector.class);
    // apply id generators
    final Object idGeneratorStrategyProviderSetting = configurationValues.remove(AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER);
    if (idGeneratorStrategyProviderSetting != null) {
        final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector.resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting);
        final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr.getService(MutableIdentifierGeneratorFactory.class);
        if (identifierGeneratorFactory == null) {
            throw persistenceException("Application requested custom identifier generator strategies, " + "but the MutableIdentifierGeneratorFactory could not be found");
        }
        for (Map.Entry<String, Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
            identifierGeneratorFactory.register(entry.getKey(), entry.getValue());
        }
    }
}
Also used : MutableIdentifierGeneratorFactory(org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory) IdentifierGeneratorStrategyProvider(org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider) UnloadedClass(org.hibernate.bytecode.enhance.spi.UnloadedClass) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 StrategySelector (org.hibernate.boot.registry.selector.spi.StrategySelector)1 UnloadedClass (org.hibernate.bytecode.enhance.spi.UnloadedClass)1 MutableIdentifierGeneratorFactory (org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory)1 IdentifierGeneratorStrategyProvider (org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider)1