Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Hibernate OGM, Domain model persistence for NoSQL datastores
   *
   * License: GNU Lesser General Public License (LGPL), version 2.1 or later
   * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
   */
  package org.hibernate.ogm.id.impl;
  
 
A table-based id generator. Inspired by ORM's org.hibernate.id.enhanced.TableGenerator. Refer to its JavaDoc for some design considerations.
Configuration parameters
NAMEDEFAULTDESCRIPTION
TABLE_PARAMDEF_TABLEThe name of the table to use to store/retrieve values
VALUE_COLUMN_PARAMDEF_VALUE_COLUMNThe name of column which holds the sequence value for the given segment
SEGMENT_COLUMN_PARAMDEF_SEGMENT_COLUMNThe name of the column which holds the segment key
SEGMENT_VALUE_PARAMDEF_SEGMENT_VALUEThe value indicating which segment is used by this generator; refers to values in the SEGMENT_COLUMN_PARAM column
OgmGeneratorBase.INITIAL_PARAMOgmGeneratorBase.DEFAULT_INITIAL_VALUEThe initial value to be stored for the given segment
OgmGeneratorBase.INCREMENT_PARAMOgmGeneratorBase.DEFAULT_INCREMENT_SIZEThe increment size for the underlying segment; see the discussion on org.hibernate.id.enhanced.Optimizer for more details.
OgmGeneratorBase.OPT_PARAMdepends on defined increment sizeAllows explicit definition of which optimization strategy to use

Author(s):
Steve Ebersole
Emmanuel Bernard <emmanuel@hibernate.org>
Gunnar Morling
 
 public class OgmTableGenerator extends OgmGeneratorBase implements Configurable {
 
 
 	public static final String TABLE_PARAM = .;
 	public static final String DEF_TABLE = .;
 
 
 
	private static final Log log = LoggerFactory.make();
	private volatile GridType identifierValueGridType;
	private String tableName;
	}

Type mapping for the identifier.

Returns:
The identifier type mapping.
	public final Type getIdentifierType() {
	}

The name of the table in which we store this generator's persistent state.

Returns:
The table name.
	public final String getTableName() {
		return ;
	}

The name of the column in which we store the segment to which each row belongs. The value here acts as PK.

Returns:
The segment column name
	public final String getSegmentColumnName() {
	}
	public void configure(Type typeProperties paramsDialect dialectthrows MappingException {
		super.configuretypeparamsdialect );
		 = determineGeneratorTableNameparamsdialect );
		 = determineValueColumnNameparamsdialect );
	}

Determine the table name to use for the generator values.

Called during configuration.

Parameters:
params The params supplied in the generator config (plus some standard useful extras).
dialect The dialect in effect
Returns:
The table name to use.
See also:
getTableName()
	protected String determineGeneratorTableName(Properties paramsDialect dialect) {
		String name = ConfigurationHelper.getStringparams );
		boolean isGivenNameUnqualified = name.indexOf'.' ) < 0;
		if ( isGivenNameUnqualified ) {
			name = normalizer.normalizeIdentifierQuotingname );
			if ( schemaName != null ) {
			}
			if ( catalogName != null ) {
			}
		}
		else {
			// if already qualified there is not much we can do in a portable manner so we pass it
			// through and assume the user has set up the name correctly.
		}
		return name;
	}

Determine the name of the column used to indicate the segment for each row. This column acts as the primary key.

Called during configuration.

Parameters:
params The params supplied in the generator config (plus some standard useful extras).
dialect The dialect in effect
Returns:
The name of the segment column
See also:
getSegmentColumnName()
	protected String determineSegmentColumnName(Properties paramsDialect dialect) {
		String name = ConfigurationHelper.getStringparams );
		return dialect.quotenormalizer.normalizeIdentifierQuotingname ) );
	}

Determine the name of the column in which we will store the generator persistent value.

Called during configuration.

Parameters:
params The params supplied in the generator config (plus some standard useful extras).
dialect The dialect in effect
Returns:
The name of the value column
	protected String determineValueColumnName(Properties paramsDialect dialect) {
		String name = ConfigurationHelper.getStringparams );
		return dialect.quotenormalizer.normalizeIdentifierQuotingname ) );
	}

Determine the segment value corresponding to this generator instance.

Called during configuration.

Parameters:
params The params supplied in the generator config (plus some standard useful extras).
Returns:
The name of the value column
	protected String determineSegmentValue(Properties params) {
		String segmentValue = params.getProperty );
		if ( StringHelper.isEmptysegmentValue ) ) {
			segmentValue = determineDefaultSegmentValueparams );
		}
		return segmentValue;
	}

Used in the cases where determineSegmentValue(java.util.Properties) is unable to determine the value to use.

Parameters:
params The params supplied in the generator config (plus some standard useful extras).
Returns:
The default segment value to use.
		boolean preferSegmentPerEntity = ConfigurationHelper.getBooleanparamsfalse );
		String defaultToUse = preferSegmentPerEntity ? params.getProperty. ) : ;
		.infof"explicit segment value for id generator [%1$s.%2$s] suggested; using default [%3$s]"defaultToUse );
		return defaultToUse;
	}
		defineGridTypessession );
		final String segmentName = (StringnullSafeSet(
		);
		return IdSourceKey.forTablesegmentName );
	}
	private Object nullSafeSet(GridType typeObject valueString columnNameSessionImplementor session) {
		Tuple tuple = new Tuple();
		type.nullSafeSettuplevaluenew String[] { columnName }, session );
		return tuple.getcolumnName );
	}
	private void defineGridTypes(SessionImplementor session) {
		if (  == null ) {
		}
	}
New to GrepCode? Check out our FAQ X