Example usage for org.hibernate.cfg EJB3NamingStrategy INSTANCE

List of usage examples for org.hibernate.cfg EJB3NamingStrategy INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.cfg EJB3NamingStrategy INSTANCE.

Prototype

NamingStrategy INSTANCE

To view the source code for org.hibernate.cfg EJB3NamingStrategy INSTANCE.

Click Source Link

Usage

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

License:Apache License

/**
 * Creates a new sequence if necessary.//from w  w  w. ja va  2s  .co m
 *
 * @param sequenceName the sequence to get the next set of values for
 * @return the generator
 */
private MultipleHiLoPerTableGenerator configure(String sequenceName) {
    Properties params = new Properties();
    params.put(MultipleHiLoPerTableGenerator.ID_TABLE, "CMS_SEQUENCE");
    params.put(MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, "SEQ_NAME");
    params.put(MultipleHiLoPerTableGenerator.PK_VALUE_NAME, sequenceName);
    params.put(MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, "NEXT_HI");
    params.put(MultipleHiLoPerTableGenerator.MAX_LO, MAXIMUM_LO);
    params.put(MultipleHiLoPerTableGenerator.IDENTIFIER_NORMALIZER, new ObjectNameNormalizer() {
        /**
         * Returns false.
         */
        protected boolean isUseQuotedIdentifiersGlobally() {
            return false;
        }

        /**
         * Returns the default naming strategy.
         */
        protected NamingStrategy getNamingStrategy() {
            return EJB3NamingStrategy.INSTANCE;
        }
    });

    Session sess = (Session) em.getDelegate();
    SessionFactoryImplementor impl = (SessionFactoryImplementor) sess.getSessionFactory();
    MultipleHiLoPerTableGenerator generator = new MultipleHiLoPerTableGenerator();
    generator.configure(LongType.INSTANCE, params, impl.getDialect());
    generators.put(sequenceName, generator);
    return generator;
}