List of usage examples for org.hibernate.id.enhanced TableGenerator VALUE_COLUMN_PARAM
String VALUE_COLUMN_PARAM
To view the source code for org.hibernate.id.enhanced TableGenerator VALUE_COLUMN_PARAM.
Click Source Link
From source file:com.manydesigns.portofino.persistence.hibernate.HibernateConfig.java
License:Open Source License
private void manageTableGenerator(Mappings mappings, Table tab, SimpleValue id, com.manydesigns.portofino.model.database.TableGenerator generator) { id.setIdentifierGeneratorStrategy("enhanced-table"); Properties params = new Properties(); params.put(TableGenerator.TABLE, tab); params.put(TableGenerator.TABLE_PARAM, escapeName(generator.getTable())); params.put(PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer()); params.put(TableGenerator.SEGMENT_COLUMN_PARAM, escapeName(generator.getKeyColumn())); params.put(TableGenerator.SEGMENT_VALUE_PARAM, generator.getKeyValue()); params.put(TableGenerator.VALUE_COLUMN_PARAM, escapeName(generator.getValueColumn())); params.setProperty(TableGenerator.SCHEMA, escapeName(tab.getSchema())); id.setIdentifierGeneratorProperties(params); id.setNullValue(null);//from ww w.j av a2 s. c o m }
From source file:com.sapienter.jbilling.server.util.db.HibernateIdGenerator.java
License:Open Source License
/** * Constructs a new ID generator for the given segment. If the segment does * not exist in the sequence table, it will be created with the newly generated * id values starting from zero.//from w w w. j av a 2s. com * * * @param segmentValue jbilling sequence name (value of the 'name' column) */ public HibernateIdGenerator(String segmentValue) { /* I consider this code to be a "horrific sin against nature and a total affront to the programming gods", but it's the only way to gain access to Hibernates IdentifierGenerator framework. Future versions of Hibernate may change the underlying implementation which will break this code. */ Properties configuration = new Properties(); configuration.setProperty(TableGenerator.TABLE_PARAM, "jbilling_seqs"); configuration.setProperty(TableGenerator.SEGMENT_COLUMN_PARAM, "name"); configuration.setProperty(TableGenerator.SEGMENT_VALUE_PARAM, segmentValue); configuration.setProperty(TableGenerator.VALUE_COLUMN_PARAM, "next_id"); configuration.setProperty(TableGenerator.INCREMENT_PARAM, "100"); sessionFactory = ((SessionFactory) Context.getBean(Context.Name.HIBERNATE_SESSION)); generator = IdentifierGeneratorFactory.create("org.hibernate.id.enhanced.TableGenerator", new IntegerType(), configuration, ((SessionFactoryImpl) sessionFactory).getDialect()); }
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; }/*from w w w .j a v a 2s.c o m*/ 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; }