List of usage examples for org.hibernate.id.enhanced SequenceStyleGenerator configure
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException
From source file:net.sf.beanlib.hibernate4.Hibernate4SequenceGenerator.java
License:Apache License
/** Returns the identifier generator created for the specified sequence and session. */ private static IdentifierGenerator createIdentifierGenerator(String sequenceName, Session session) { SessionFactory sessionFactory = session.getSessionFactory(); if (!(sessionFactory instanceof SessionFactoryImpl)) { throw new IllegalStateException("Not yet know how to handle the session factory of the given session!"); }//from www.jav a 2 s .c om SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory; // Dialect dialect = sessionFactoryImpl.getDialect(); ServiceRegistry registry = sessionFactoryImpl.getServiceRegistry(); Properties params = new Properties(); params.setProperty("sequence", sequenceName); SequenceStyleGenerator sequenceStyleGenerator = new SequenceStyleGenerator(); sequenceStyleGenerator.configure(LongType.INSTANCE, params, (ServiceRegistry) registry); // SequenceGenerator sequenceGenerator = new SequenceGenerator(); // sequenceGenerator.configure(LongType.INSTANCE, params, dialect); return sequenceStyleGenerator; }