mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-03-03 00:09:19 +00:00
HHH-6084 define id strategy provider in HEM
This commit is contained in:
parent
8ca87139de
commit
cea2cfdf44
@ -256,6 +256,11 @@ public class AvailableSettings {
|
||||
*/
|
||||
public static final String SESSION_FACTORY_OBSERVER = "hibernate.ejb.session_factory_observer";
|
||||
|
||||
/**
|
||||
* IdentifierGeneratorStrategyRegisterer class name, the class must have a no-arg constructor
|
||||
*/
|
||||
public static final String IDENTIFIER_GENERATOR_STRATEGY_PROVIDER = "hibernate.ejb.identifier_generator_strategy_provider";
|
||||
|
||||
/**
|
||||
* Event configuration should follow the following pattern
|
||||
* hibernate.ejb.event.[eventType] f.q.c.n.EventListener1, f.q.c.n.EventListener12 ...
|
||||
|
@ -77,6 +77,7 @@
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.cfg.SettingsFactory;
|
||||
import org.hibernate.cfg.annotations.reflection.XMLContext;
|
||||
import org.hibernate.ejb.cfg.spi.IdentifierGeneratorStrategyProvider;
|
||||
import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider;
|
||||
import org.hibernate.ejb.instrument.InterceptFieldClassFileTransformer;
|
||||
import org.hibernate.ejb.packaging.JarVisitorFactory;
|
||||
@ -91,6 +92,7 @@
|
||||
import org.hibernate.ejb.util.NamingHelper;
|
||||
import org.hibernate.engine.FilterDefinition;
|
||||
import org.hibernate.event.EventListeners;
|
||||
import org.hibernate.id.factory.DefaultIdentifierGeneratorFactory;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.persister.PersisterClassProvider;
|
||||
@ -1074,6 +1076,21 @@ else if ( propertyKey.startsWith( AvailableSettings.JACC_PREFIX )
|
||||
cfg.setSessionFactoryObserver( observer );
|
||||
}
|
||||
|
||||
final IdentifierGeneratorStrategyProvider strategyProvider = instantiateCustomClassFromConfiguration(
|
||||
preparedProperties,
|
||||
null,
|
||||
null,
|
||||
AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER,
|
||||
"Identifier generator strategy provider",
|
||||
IdentifierGeneratorStrategyProvider.class
|
||||
);
|
||||
if ( strategyProvider != null ) {
|
||||
final DefaultIdentifierGeneratorFactory identifierGeneratorFactory = cfg.getIdentifierGeneratorFactory();
|
||||
for ( Map.Entry<String,Class<?>> entry : strategyProvider.getStrategies().entrySet() ) {
|
||||
identifierGeneratorFactory.register( entry.getKey(), entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( jaccKeys.size() > 0 ) {
|
||||
addSecurity( jaccKeys, preparedProperties, workingVars );
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
|
||||
* as indicated by the @authors tag. All rights reserved.
|
||||
* See the copyright.txt in the distribution for a
|
||||
* full listing of individual contributors.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License, v. 2.1.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT A
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
* You should have received a copy of the GNU Lesser General Public License,
|
||||
* v.2.1 along with this distribution; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
package org.hibernate.ejb.cfg.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provide a set of IdentifierGenerator strategies allowing to override the Hibernate Core default ones
|
||||
*
|
||||
* @author Emmanuel Bernard <emmanuel@hibernate.org>
|
||||
*/
|
||||
public interface IdentifierGeneratorStrategyProvider {
|
||||
/**
|
||||
* set of strategy / generator class pairs to register as accepted strategies
|
||||
*/
|
||||
Map<String,Class<?>> getStrategies();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user