List of usage examples for org.hibernate.id PersistentIdentifierGenerator TABLE
String TABLE
To view the source code for org.hibernate.id PersistentIdentifierGenerator TABLE.
Click Source Link
From source file:com.expressui.core.util.TableNameSequenceGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if (params.getProperty(SEQUENCE) == null || params.getProperty(SEQUENCE).length() == 0 && dialect.supportsSequences()) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); if (tableName != null) { String seqName = "SEQ_" + tableName; params.setProperty(SEQUENCE, seqName); }/* w ww. j a v a2s. co m*/ } super.configure(type, params, dialect); }
From source file:com.literatejava.hibernate.allocator.LinearBlockAllocator.java
License:Open Source License
public void configure(Type type, Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get(IDENTIFIER_NORMALIZER); this.tableName = ConfigurationHelper.getString(ALLOC_TABLE, params, DEFAULT_TABLE); this.sequenceColumn = ConfigurationHelper.getString(SEQUENCE_COLUMN, params, DEFAULT_SEQUENCE_COLUMN); this.allocColumn = ConfigurationHelper.getString(ALLOC_COLUMN, params, DEFAULT_ALLOC_COLUMN); // get SequenceName; default to Entities' TableName. // -/* w ww .j a v a2 s .com*/ this.sequenceName = ConfigurationHelper.getString(SEQUENCE_NAME, params, params.getProperty(PersistentIdentifierGenerator.TABLE)); if (sequenceName == null) { throw new IdentifierGenerationException( "LinearBlockAllocator: '" + SEQUENCE_NAME + "' must be specified"); } this.blockSize = ConfigurationHelper.getInt(BLOCK_SIZE, params, DEFAULT_BLOCK_SIZE); if (blockSize < 1) { blockSize = 1; } // qualify Table Name, if necessary; // -- if (tableName.indexOf('.') < 0) { String schemaName = normalizer.normalizeIdentifierQuoting(params.getProperty(SCHEMA)); String catalogName = normalizer.normalizeIdentifierQuoting(params.getProperty(CATALOG)); this.tableName = Table.qualify(catalogName, schemaName, tableName); } // build SQL strings; // -- use appendLockHint(LockMode) for now, as that is how Hibernate's generators do it. // this.query = "select " + allocColumn + " from " + dialect.appendLockHint(LockMode.PESSIMISTIC_WRITE, tableName) + " where " + sequenceColumn + " = ?" + dialect.getForUpdateString(); this.update = "update " + tableName + " set " + allocColumn + " = ? where " + sequenceColumn + " = ? and " + allocColumn + " = ?"; // setup Return Type & Result Holder. // -- this.returnType = type; this.returnClass = type.getReturnedClass(); this.resultFactory = IdentifierGeneratorHelper.getIntegralDataTypeHolder(returnClass); // done. }
From source file:com.purebred.core.util.TableNameSequenceGenerator.java
License:Open Source License
public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if (params.getProperty(SEQUENCE) == null || params.getProperty(SEQUENCE).length() == 0) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); if (tableName != null) { String seqName = "SEQ_" + tableName; params.setProperty(SEQUENCE, seqName); }// w w w . j av a 2s . c o m } super.configure(type, params, dialect); }
From source file:ome.tools.hibernate.MySeqGenerator.java
License:Open Source License
/** * If the parameters do not contain a {@link SequenceGenerator#SEQUENCE} * name, we assign one based on the table name. *//*from w w w . j a va 2 s . co m*/ @Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if (params.getProperty(SEQUENCE) == null || params.getProperty(SEQUENCE).length() == 0) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); if (tableName != null) { String seqName = "seq_" + tableName; params.setProperty(SEQUENCE, seqName); } } super.configure(type, params, dialect); }
From source file:org.beangle.commons.orm.hibernate.TableSeqGenerator.java
License:Open Source License
/** * If the parameters do not contain a {@link SequenceGenerator#SEQUENCE} name, we assign one * based on the table name.//from www . j a v a 2 s . c o m */ public void configure(Type type, Properties params, Dialect dialect) { if (Strings.isEmpty(params.getProperty(SEQUENCE_PARAM))) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); String pk = params.getProperty(PersistentIdentifierGenerator.PK); if (null != tableName) { String seqName = Strings.replace(sequencePattern, "{table}", tableName); seqName = Strings.replace(seqName, "{pk}", pk); if (seqName.length() > MaxLength) { logger.error("{}'s length >=30, wouldn't be supported in some db!", seqName); } String entityName = params.getProperty(IdentifierGenerator.ENTITY_NAME); if (null != entityName && null != namingStrategy) { String schema = namingStrategy.getSchema(entityName); if (null != schema) seqName = schema + "." + seqName; } params.setProperty(SEQUENCE_PARAM, seqName); } } super.configure(type, params, dialect); }
From source file:org.beangle.model.persist.hibernate.support.TableSeqGenerator.java
License:Open Source License
/** * If the parameters do not contain a {@link SequenceGenerator#SEQUENCE} name, we assign one * based on the table name.//from w w w .j av a 2 s. c o m */ public void configure(Type type, Properties params, Dialect dialect) { if (StringUtils.isEmpty(params.getProperty(SEQUENCE_PARAM))) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); String pk = params.getProperty(PersistentIdentifierGenerator.PK); if (tableName != null) { String seqName = StringUtils.replace(sequencePattern, "{table}", tableName); seqName = StringUtils.replace(seqName, "{pk}", pk); if (seqName.length() > MaxLength) { logger.error("{}'s length has greate more then 30, database will not be supported!", seqName); } params.setProperty(SEQUENCE_PARAM, seqName); } } super.configure(type, params, dialect); }
From source file:org.beangle.orm.hibernate.TableSeqGenerator.java
License:Open Source License
/** * If the parameters do not contain a {@link SequenceGenerator#SEQUENCE} name, we assign one * based on the table name./*from w ww . ja va 2s. co m*/ */ public void configure(Type type, Properties params, Dialect dialect) { if (Strings.isEmpty(params.getProperty(SEQUENCE_PARAM))) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); String pk = params.getProperty(PersistentIdentifierGenerator.PK); if (null != tableName) { String seqName = Strings.replace(sequencePattern, "{table}", tableName); seqName = Strings.replace(seqName, "{pk}", pk); if (seqName.length() > MaxLength) { logger.warn("{}'s length >=30, wouldn't be supported in some db!", seqName); } String entityName = params.getProperty(IdentifierGenerator.ENTITY_NAME); if (null != entityName && null != namingStrategy) { String schema = namingStrategy.getSchema(entityName); if (null != schema) seqName = schema + "." + seqName; } params.setProperty(SEQUENCE_PARAM, seqName); } } super.configure(type, params, dialect); }
From source file:org.sonar.core.persistence.dialect.OracleSequenceGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); if (tableName != null) { StringBuilder sequenceNameBuilder = new StringBuilder(); sequenceNameBuilder.append(tableName); sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX); params.setProperty(SEQUENCE, StringUtils.upperCase(sequenceNameBuilder.toString())); }/* w w w . j av a2s . c om*/ super.configure(type, params, dialect); }
From source file:org.sonar.core.persistence.dialect.OracleSequenceGeneratorTest.java
License:Open Source License
@Test public void sequenceNameShouldFollowRailsConventions() { Properties props = new Properties(); props.setProperty(PersistentIdentifierGenerator.TABLE, "my_table"); props.setProperty(PersistentIdentifierGenerator.PK, "id"); OracleSequenceGenerator generator = new OracleSequenceGenerator(); generator.configure(null, props, new Oracle.Oracle10gWithDecimalDialect()); assertThat(generator.getSequenceName()).isEqualTo("MY_TABLE_SEQ"); }
From source file:org.sonar.core.persistence.dialect.PostgreSQLSequenceGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); String columnName = params.getProperty(PersistentIdentifierGenerator.PK); if (tableName != null && columnName != null) { StringBuilder sequenceNameBuilder = new StringBuilder(); sequenceNameBuilder.append(tableName); sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR); sequenceNameBuilder.append(columnName); sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR); sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX); params.setProperty(SEQUENCE, sequenceNameBuilder.toString()); }//from www. j a va 2 s . c o m super.configure(type, params, dialect); }