Search in sources :

Example 1 with Configurable

use of org.hibernate.id.Configurable in project hibernate-orm by hibernate.

the class DefaultIdentifierGeneratorFactory method createIdentifierGenerator.

@Override
public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
    try {
        Class clazz = getIdentifierGeneratorClass(strategy);
        IdentifierGenerator identifierGenerator = (IdentifierGenerator) clazz.newInstance();
        if (identifierGenerator instanceof Configurable) {
            ((Configurable) identifierGenerator).configure(type, config, serviceRegistry);
        }
        return identifierGenerator;
    } catch (Exception e) {
        final String entityName = config.getProperty(IdentifierGenerator.ENTITY_NAME);
        throw new MappingException(String.format("Could not instantiate id generator [entity-name=%s]", entityName), e);
    }
}
Also used : Configurable(org.hibernate.id.Configurable) MappingException(org.hibernate.MappingException) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) IdentifierGenerator(org.hibernate.id.IdentifierGenerator) MappingException(org.hibernate.MappingException)

Aggregations

MappingException (org.hibernate.MappingException)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1 Configurable (org.hibernate.id.Configurable)1 IdentifierGenerator (org.hibernate.id.IdentifierGenerator)1