Example usage for org.hibernate.id SequenceGenerator SequenceGenerator

List of usage examples for org.hibernate.id SequenceGenerator SequenceGenerator

Introduction

In this page you can find the example usage for org.hibernate.id SequenceGenerator SequenceGenerator.

Prototype

SequenceGenerator

Source Link

Usage

From source file:com.googlecode.sarasvati.hib.SarasvatiIdentifierGenerator.java

License:Open Source License

@Override
public void configure(final Type type, final Properties properties, final Dialect dialect)
        throws MappingException {
    if (dialect.supportsIdentityColumns()) {
        generator = new IdentityGenerator();
    } else {/* w w  w . jav  a  2 s .  c om*/
        final SequenceGenerator seqGenerator = new SequenceGenerator();
        seqGenerator.configure(type, properties, dialect);
        generator = seqGenerator;
    }
}

From source file:org.hyperic.hibernate.id.ComboGenerator.java

License:Open Source License

public void configure(Type type, Properties params, Dialect d) throws MappingException {
    if (_log.isDebugEnabled())
        _log.debug("Configuring ComboGenerator for dialect [" + d + "]");

    HQDialect hqDialect = (HQDialect) d;
    if (hqDialect.usesSequenceGenerator()) {
        _delegate = new SequenceGenerator();
    } else {//  w w w.j  av a  2s  .c  om
        _delegate = new HQMultipleHiLoPerTableGenerator();

        // Table containing the sequences
        params.put(HQMultipleHiLoPerTableGenerator.ID_TABLE, "HQ_SEQUENCE");

        // Name of the column containing the 'sequence' name
        params.put(HQMultipleHiLoPerTableGenerator.PK_COLUMN_NAME, "seq_name");

        // Name of the column containing the value for the sequence
        params.put(HQMultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, "seq_val");

        // How many IDs do we increment and cache?
        params.put(HQMultipleHiLoPerTableGenerator.MAX_LO, "100");

        // What is the initial 'hi' value?
        params.put(HQMultipleHiLoPerTableGenerator.INITIAL_HI, "100");
    }
    ((Configurable) _delegate).configure(type, params, d);

}