Example usage for org.hibernate.id.enhanced TableGenerator INITIAL_PARAM

List of usage examples for org.hibernate.id.enhanced TableGenerator INITIAL_PARAM

Introduction

In this page you can find the example usage for org.hibernate.id.enhanced TableGenerator INITIAL_PARAM.

Prototype

String INITIAL_PARAM

To view the source code for org.hibernate.id.enhanced TableGenerator INITIAL_PARAM.

Click Source Link

Document

Indicates the initial value to use.

Usage

From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java

License:Open Source License

private TableGenerator getTableGenerator(String seqName, Long startValue)
        throws InstantiationException, IllegalAccessException {

    TableGenerator tg = _generatorCache.get(seqName);
    if (tg != null && (startValue == null || startValue.equals(tg.getInitialValue()))) {
        return tg;
    }/*from w ww.  j a  v  a  2 s.c o m*/

    Properties props = new Properties();
    props.put(TableGenerator.TABLE_PARAM, "cs_sequences");
    props.put(TableGenerator.SEGMENT_COLUMN_PARAM, "name");
    props.put(TableGenerator.SEGMENT_VALUE_PARAM, seqName);
    props.put(TableGenerator.VALUE_COLUMN_PARAM, "value");
    props.put(TableGenerator.OPT_PARAM, "none");
    props.put(TableGenerator.IDENTIFIER_NORMALIZER, _conf.createMappings().getObjectNameNormalizer());

    if (startValue != null) {
        props.put(TableGenerator.INITIAL_PARAM, startValue.intValue());
    }

    tg = TableGenerator.class.newInstance();

    Dialect dialect = ((SessionFactoryImplementor) _sessionFactory).getJdbcServices().getDialect();
    tg.configure(_sessionFactory.getTypeHelper().basic(Long.class), props, dialect);
    _generatorCache.put(seqName, tg);

    return tg;

}