Example usage for org.hibernate.id MultipleHiLoPerTableGenerator generate

List of usage examples for org.hibernate.id MultipleHiLoPerTableGenerator generate

Introduction

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

Prototype

public synchronized Serializable generate(final SharedSessionContractImplementor session, Object obj) 

Source Link

Usage

From source file:gov.medicaid.services.impl.SequenceGeneratorBean.java

License:Apache License

/**
 * Retrieves the next value for the sequence.
 *
 * @param sequenceName the name of the sequence
 * @return the next value (using HI-LO algorithm)
 *//*from   w w  w  . j av a 2 s . co  m*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public long getNextValue(String sequenceName) {
    if (generators == null) {
        generators = new HashMap<String, MultipleHiLoPerTableGenerator>();
    }
    MultipleHiLoPerTableGenerator generator = generators.get(sequenceName);
    if (generator == null) {
        generator = configure(sequenceName);
    }
    Session sess = (Session) em.getDelegate();
    return ((Number) generator.generate((SessionImplementor) sess, null)).longValue();
}