List of usage examples for org.hibernate.id PersistentIdentifierGenerator PK
String PK
To view the source code for org.hibernate.id PersistentIdentifierGenerator PK.
Click Source Link
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 w w w . ja v a2 s . 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.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 ww w. j av a2 s. co 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 ww w. j a va2 s. 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.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 w ww .j av a 2 s .co m super.configure(type, params, dialect); }
From source file:org.sonar.core.persistence.dialect.PostgreSQLSequenceGeneratorTest.java
License:Open Source License
@Test public void sequenceNameShouldFollowRailsConventions() { Properties props = new Properties(); props.setProperty(PersistentIdentifierGenerator.TABLE, "my_table"); props.setProperty(PersistentIdentifierGenerator.PK, "id"); PostgreSQLSequenceGenerator generator = new PostgreSQLSequenceGenerator(); generator.configure(null, props, new PostgreSql.PostgreSQLWithDecimalDialect()); assertThat(generator.getSequenceName()).isEqualTo("my_table_id_seq"); }
From source file:org.sonar.jpa.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(), is("MY_TABLE_SEQ")); }
From source file:org.sonar.jpa.dialect.PostgreSQLSequenceGenerator.java
License:Open Source License
@Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { 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()); }// w w w . jav a 2 s . c o m super.configure(type, params, dialect); }
From source file:org.sonar.jpa.dialect.PostgreSQLSequenceGeneratorTest.java
License:Open Source License
@Test public void sequenceNameShouldFollowRailsConventions() { Properties props = new Properties(); props.setProperty(PersistentIdentifierGenerator.TABLE, "my_table"); props.setProperty(PersistentIdentifierGenerator.PK, "id"); PostgreSQLSequenceGenerator generator = new PostgreSQLSequenceGenerator(); generator.configure(null, props, new PostgreSql.PostgreSQLWithDecimalDialect()); assertThat(generator.getSequenceName(), is("my_table_id_seq")); }