Tabnine Logo
TableGenerator
Code IndexAdd Tabnine to your IDE (free)

How to use
TableGenerator
in
org.hibernate.id.enhanced

Best Java code snippets using org.hibernate.id.enhanced.TableGenerator (Showing top 15 results out of 315)

origin: hibernate/hibernate-orm

    dialect
);
table.addInitCommand( generateInsertInitCommand() );
this.selectQuery = buildSelectQuery( dialect );
this.updateQuery = buildUpdateQuery();
this.insertQuery = buildInsertQuery();
origin: BroadleafCommerce/BroadleafCommerce

@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
  if (params.get("table_name") == null) {
    params.put("table_name", "SEQUENCE_GENERATOR");
  }
  if (params.get("segment_column_name") == null) {
    params.put("segment_column_name", DEFAULT_SEGMENT_COLUMN_NAME);
  }
  if (params.get("value_column_name") == null) {
    params.put("value_column_name", DEFAULT_VALUE_COLUMN_NAME);
  }
  if (params.get("increment_size") == null) {
    params.put("increment_size", DEFAULT_INCREMENT_SIZE);
  }
  super.configure(type, params, dialect);
  entityName = (String) params.get(ENTITY_NAME_PARAM);
}
origin: hibernate/hibernate-orm

/**
 * Determine the segment value corresponding to this generator instance.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getSegmentValue()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @return The name of the value column
 */
@SuppressWarnings("WeakerAccess")
protected String determineSegmentValue(Properties params) {
  String segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
  if ( StringHelper.isEmpty( segmentValue ) ) {
    segmentValue = determineDefaultSegmentValue( params );
  }
  return segmentValue;
}
origin: hibernate/hibernate-orm

@Override
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
  storeLastUsedValue = serviceRegistry.getService( ConfigurationService.class )
      .getSetting( AvailableSettings.TABLE_GENERATOR_STORE_LAST_USED, StandardConverters.BOOLEAN, true );
  identifierType = type;
  final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
  qualifiedTableName = determineGeneratorTableName( params, jdbcEnvironment, serviceRegistry );
  segmentColumnName = determineSegmentColumnName( params, jdbcEnvironment );
  valueColumnName = determineValueColumnName( params, jdbcEnvironment );
  segmentValue = determineSegmentValue( params );
  segmentValueLength = determineSegmentColumnSize( params );
  initialValue = determineInitialValue( params );
  incrementSize = determineIncrementSize( params );
  final String optimizationStrategy = ConfigurationHelper.getString(
      OPT_PARAM,
      params,
      OptimizerFactory.determineImplicitOptimizerName( incrementSize, params )
  );
  int optimizerInitialValue = ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 );
  optimizer = OptimizerFactory.buildOptimizer(
      optimizationStrategy,
      identifierType.getReturnedClass(),
      incrementSize,
      optimizerInitialValue
  );
}
origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
  identifierType = type;
  tableName = determineGeneratorTableName( params, dialect );
  segmentColumnName = determineSegmentColumnName( params, dialect );
  valueColumnName = determineValueColumnName( params, dialect );
  segmentValue = determineSegmentValue( params );
  segmentValueLength = determineSegmentColumnSize( params );
  initialValue = determineInitialValue( params );
  incrementSize = determineIncrementSize( params );
  this.selectQuery = buildSelectQuery( dialect );
  this.updateQuery = buildUpdateQuery();
  this.insertQuery = buildInsertQuery();
  // if the increment size is greater than one, we prefer pooled optimization; but we
  // need to see if the user prefers POOL or POOL_LO...
  String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
      ? OptimizerFactory.StandardOptimizerDescriptor.POOLED_LO.getExternalName()
      : OptimizerFactory.StandardOptimizerDescriptor.POOLED.getExternalName();
  final String defaultOptimizerStrategy = incrementSize <= 1
      ? OptimizerFactory.StandardOptimizerDescriptor.NONE.getExternalName()
      : defaultPooledOptimizerStrategy;
  final String optimizationStrategy = ConfigurationHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
  optimizer = OptimizerFactory.buildOptimizer(
      optimizationStrategy,
      identifierType.getReturnedClass(),
      incrementSize,
      ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 )
  );
}
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-9850" )
public void testNewGeneratorTableCreationOnDb2() {
  StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
      .applySetting( AvailableSettings.DIALECT, DB2Dialect.class.getName() )
      .build();
  try {
    Metadata metadata = new MetadataSources( ssr )
        .buildMetadata();
    assertEquals( 0, metadata.getDatabase().getDefaultNamespace().getTables().size() );
    TableGenerator generator = new TableGenerator();
    Properties properties = new Properties();
    generator.configure( IntegerType.INSTANCE, properties, ssr );
    generator.registerExportables( metadata.getDatabase() );
    assertEquals( 1, metadata.getDatabase().getDefaultNamespace().getTables().size() );
    final Table table = metadata.getDatabase().getDefaultNamespace().getTables().iterator().next();
    final String[] createCommands = new DB2Dialect().getTableExporter().getSqlCreateStrings( table, metadata );
    assertContains( "sequence_name varchar(255) not null", createCommands[0] );
  }
  finally {
    StandardServiceRegistryBuilder.destroy( ssr );
  }
}
origin: com.github.mg365/mg-entity

if(instanceSeqId == null) {
  logger.warn("没有找到对应的实例,采用缺省的的主键生成方式");
  id = "" + super.generate(session, obj);
    tableGenerator = new TableGenerator();
    tableGenerator.configure(new IntegerType(), defaultParams, defaultDialet);
    multiTenantTableGenerator.put(instanceSeqId, tableGenerator);
    logger.info("创建{}的主键生成器。", instanceSeqId);
  id = "" + tableGenerator.generate(session, obj);
origin: org.hibernate/com.springsource.org.hibernate

@Override
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
  identifierType = type;
  tableName = determineGeneratorTableName( params, dialect );
  segmentColumnName = determineSegmentColumnName( params, dialect );
  valueColumnName = determineValueColumnName( params, dialect );
  segmentValue = determineSegmentValue( params );
  segmentValueLength = determineSegmentColumnSize( params );
  initialValue = determineInitialValue( params );
  incrementSize = determineIncrementSize( params );
  this.selectQuery = buildSelectQuery( dialect );
  this.updateQuery = buildUpdateQuery();
  this.insertQuery = buildInsertQuery();
  // if the increment size is greater than one, we prefer pooled optimization; but we
  // need to see if the user prefers POOL or POOL_LO...
  String defaultPooledOptimizerStrategy = ConfigurationHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
      ? OptimizerFactory.StandardOptimizerDescriptor.POOLED_LO.getExternalName()
      : OptimizerFactory.StandardOptimizerDescriptor.POOLED.getExternalName();
  final String defaultOptimizerStrategy = incrementSize <= 1
      ? OptimizerFactory.StandardOptimizerDescriptor.NONE.getExternalName()
      : defaultPooledOptimizerStrategy;
  final String optimizationStrategy = ConfigurationHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
  optimizer = OptimizerFactory.buildOptimizer(
      optimizationStrategy,
      identifierType.getReturnedClass(),
      incrementSize,
      ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 )
  );
}
origin: org.hibernate.orm/hibernate-core

@Override
public void configure(JavaTypeDescriptor javaTypeDescriptor, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
  storeLastUsedValue = serviceRegistry.getService( ConfigurationService.class )
      .getSetting( AvailableSettings.TABLE_GENERATOR_STORE_LAST_USED, StandardConverters.BOOLEAN, true );
  identifierType = javaTypeDescriptor;
  final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
  qualifiedTableName = determineGeneratorTableName( params, jdbcEnvironment, serviceRegistry );
  segmentColumnName = determineSegmentColumnName( params, jdbcEnvironment );
  valueColumnName = determineValueColumnName( params, jdbcEnvironment );
  segmentValue = determineSegmentValue( params );
  segmentValueLength = determineSegmentColumnSize( params );
  initialValue = determineInitialValue( params );
  incrementSize = determineIncrementSize( params );
  final String optimizationStrategy = ConfigurationHelper.getString(
      OPT_PARAM,
      params,
      OptimizerFactory.determineImplicitOptimizerName( incrementSize, params )
  );
  int optimizerInitialValue = ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 );
  optimizer = OptimizerFactory.buildOptimizer(
      optimizationStrategy,
      identifierType.getJavaType(),
      incrementSize,
      optimizerInitialValue
  );
}
origin: org.hibernate.orm/hibernate-core

    dialect
);
table.addInitCommand( generateInsertInitCommand() );
this.selectQuery = buildSelectQuery( dialect );
this.updateQuery = buildUpdateQuery();
this.insertQuery = buildInsertQuery();
origin: org.hibernate.orm/hibernate-core

/**
 * Determine the segment value corresponding to this generator instance.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getSegmentValue()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @return The name of the value column
 */
@SuppressWarnings("WeakerAccess")
protected String determineSegmentValue(Properties params) {
  String segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
  if ( StringHelper.isEmpty( segmentValue ) ) {
    segmentValue = determineDefaultSegmentValue( params );
  }
  return segmentValue;
}
origin: omero/model-psql

@Override
public void configure(Type type, Properties params, Dialect dialect)
    throws MappingException {
  super.configure(type, params, dialect);
}
origin: org.hibernate/com.springsource.org.hibernate.core

/**
 * Determine the segment value corresponding to this generator instance.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getSegmentValue()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @return The name of the value column
 */
protected String determineSegmentValue(Properties params) {
  String segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
  if ( StringHelper.isEmpty( segmentValue ) ) {
    segmentValue = determineDefaultSegmentValue( params );
  }
  return segmentValue;
}
origin: com.github.mg365/mg-entity

  @Override
  public void configure(Type type, Properties params, Dialect dialect)
      throws MappingException {
    // 如果这里写成super.configure(type, params, dialect);会造成死循环
    // 因为TableGenerator默认Integer类型主键
    this.defaultParams = params;
    this.defaultDialet = dialect;
    super.configure(new IntegerType(), params, dialect);
//        format = params.getProperty("format");
  }
 
origin: org.hibernate/com.springsource.org.hibernate

/**
 * Determine the segment value corresponding to this generator instance.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getSegmentValue()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @return The name of the value column
 */
protected String determineSegmentValue(Properties params) {
  String segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
  if ( StringHelper.isEmpty( segmentValue ) ) {
    segmentValue = determineDefaultSegmentValue( params );
  }
  return segmentValue;
}
org.hibernate.id.enhancedTableGenerator

Javadoc

An enhanced version of table-based id generation.

Unlike the simplistic legacy one (which, btw, was only ever intended for subclassing support) we "segment" the table into multiple values. Thus a single table can actually serve as the persistent storage for multiple independent generators. One approach would be to segment the values by the name of the entity for which we are performing generation, which would mean that we would have a row in the generator table for each entity name. Or any configuration really; the setup is very flexible.

In this respect it is very similar to the legacy org.hibernate.id.MultipleHiLoPerTableGenerator in terms of the underlying storage structure (namely a single table capable of holding multiple generator values). The differentiator is, as with SequenceStyleGenerator as well, the externalized notion of an optimizer.

NOTE that by default we use a single row for all generators (based on #DEF_SEGMENT_VALUE). The configuration parameter #CONFIG_PREFER_SEGMENT_PER_ENTITY can be used to change that to instead default to using a row for each entity name.

Configuration parameters:

NAME DEFAULT DESCRIPTION
#TABLE_PARAM #DEF_TABLE The name of the table to use to store/retrieve values
#VALUE_COLUMN_PARAM #DEF_VALUE_COLUMN The name of column which holds the sequence value for the given segment
#SEGMENT_COLUMN_PARAM #DEF_SEGMENT_COLUMN The name of the column which holds the segment key
#SEGMENT_VALUE_PARAM #DEF_SEGMENT_VALUE The value indicating which segment is used by this generator; refers to values in the #SEGMENT_COLUMN_PARAM column
#SEGMENT_LENGTH_PARAM #DEF_SEGMENT_LENGTH The data length of the #SEGMENT_COLUMN_PARAM column; used for schema creation
#INITIAL_PARAM #DEFAULT_INITIAL_VALUE The initial value to be stored for the given segment
#INCREMENT_PARAM #DEFAULT_INCREMENT_SIZE The increment size for the underlying segment; see the discussion on Optimizer for more details.
#OPT_PARAM depends on defined increment size Allows explicit definition of which optimization strategy to use

Most used methods

  • buildInsertQuery
  • buildSelectQuery
  • buildUpdateQuery
  • configure
  • determineDefaultSegmentValue
    Used in the cases where #determineSegmentValue is unable to determine the value to use.
  • determineGeneratorTableName
    Determine the table name to use for the generator values. Called during #configure.
  • determineIncrementSize
  • determineInitialValue
  • determineSegmentColumnName
    Determine the name of the column used to indicate the segment for each row. This column acts as the
  • determineSegmentColumnSize
    Determine the size of the #getSegmentColumnName Called during #configure.
  • determineSegmentValue
    Determine the segment value corresponding to this generator instance. Called during #configure.
  • determineValueColumnName
    Determine the name of the column in which we will store the generator persistent value. Called durin
  • determineSegmentValue,
  • determineValueColumnName,
  • generate,
  • <init>,
  • generateInsertInitCommand,
  • getSegmentColumnName,
  • getTableName,
  • getValueColumnName,
  • getIncrementSize,
  • getInitialValue

Popular in Java

  • Start an intent from android
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Kernel (java.awt.image)
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JFrame (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now