List of usage examples for org.hibernate.id.enhanced TableGenerator configure
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException
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; }// w w w . j a v a 2 s. com 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; }