Example usage for org.hibernate.id.enhanced SequenceStyleGenerator CONFIG_PREFER_SEQUENCE_PER_ENTITY

List of usage examples for org.hibernate.id.enhanced SequenceStyleGenerator CONFIG_PREFER_SEQUENCE_PER_ENTITY

Introduction

In this page you can find the example usage for org.hibernate.id.enhanced SequenceStyleGenerator CONFIG_PREFER_SEQUENCE_PER_ENTITY.

Prototype

String CONFIG_PREFER_SEQUENCE_PER_ENTITY

To view the source code for org.hibernate.id.enhanced SequenceStyleGenerator CONFIG_PREFER_SEQUENCE_PER_ENTITY.

Click Source Link

Document

Used to create dedicated sequence for each entity based on the entity name.

Usage

From source file:com.tsoft.app.domain.identifier.StringSequenceIdentifier.java

@Override
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
    final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
    final Dialect dialect = jdbcEnvironment.getDialect();

    final ConfigurationService configurationService = serviceRegistry.getService(ConfigurationService.class);
    String globalEntityIdentifierPrefix = configurationService.getSetting("entity.identifier.prefix",
            String.class, "SEQ_");

    sequencePrefix = ConfigurationHelper.getString(SEQUENCE_PREFIX, params, globalEntityIdentifierPrefix);

    final String sequencePerEntitySuffix = ConfigurationHelper.getString(
            SequenceStyleGenerator.CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params,
            SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX);

    final String defaultSequenceName = ConfigurationHelper
            .getBoolean(SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false)
                    ? params.getProperty(JPA_ENTITY_NAME) + sequencePerEntitySuffix
                    : SequenceStyleGenerator.DEF_SEQUENCE_NAME;

    sequenceCallSyntax = dialect.getSequenceNextValString(
            ConfigurationHelper.getString(SequenceStyleGenerator.SEQUENCE_PARAM, params, defaultSequenceName));
}