Java Code Examples for javax.persistence.TableGenerator#uniqueConstraints()

The following examples show how to use javax.persistence.TableGenerator#uniqueConstraints() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdGeneratorInterpreterImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void interpretTableGenerator(
		TableGenerator tableGeneratorAnnotation,
		IdentifierGeneratorDefinition.Builder definitionBuilder) {
	definitionBuilder.setName( tableGeneratorAnnotation.name() );
	definitionBuilder.setStrategy( MultipleHiLoPerTableGenerator.class.getName() );

	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.table() ) ) {
		definitionBuilder.addParam(
				MultipleHiLoPerTableGenerator.ID_TABLE,
				tableGeneratorAnnotation.table()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.catalog() ) ) {
		definitionBuilder.addParam(
				PersistentIdentifierGenerator.CATALOG,
				tableGeneratorAnnotation.catalog()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.schema() ) ) {
		definitionBuilder.addParam(
				PersistentIdentifierGenerator.SCHEMA,
				tableGeneratorAnnotation.schema()
		);
	}

	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.pkColumnName() ) ) {
		definitionBuilder.addParam(
				MultipleHiLoPerTableGenerator.PK_COLUMN_NAME,
				tableGeneratorAnnotation.pkColumnName()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.valueColumnName() ) ) {
		definitionBuilder.addParam(
				MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME,
				tableGeneratorAnnotation.valueColumnName()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.pkColumnValue() ) ) {
		definitionBuilder.addParam(
				MultipleHiLoPerTableGenerator.PK_VALUE_NAME,
				tableGeneratorAnnotation.pkColumnValue()
		);
	}
	definitionBuilder.addParam(
			MultipleHiLoPerTableGenerator.MAX_LO,
			String.valueOf( tableGeneratorAnnotation.allocationSize() - 1 )
	);

	// TODO : implement unique-constraint support
	if ( tableGeneratorAnnotation.uniqueConstraints() != null
			&& tableGeneratorAnnotation.uniqueConstraints().length > 0 ) {
		log.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() );
	}
}
 
Example 2
Source File: IdGeneratorInterpreterImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void interpretTableGenerator(
		TableGenerator tableGeneratorAnnotation,
		IdentifierGeneratorDefinition.Builder definitionBuilder) {
	definitionBuilder.setName( tableGeneratorAnnotation.name() );
	definitionBuilder.setStrategy( org.hibernate.id.enhanced.TableGenerator.class.getName() );
	definitionBuilder.addParam( org.hibernate.id.enhanced.TableGenerator.CONFIG_PREFER_SEGMENT_PER_ENTITY, "true" );

	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.catalog() ) ) {
		definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, tableGeneratorAnnotation.catalog() );
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.schema() ) ) {
		definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, tableGeneratorAnnotation.schema() );
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.table() ) ) {
		definitionBuilder.addParam(
				org.hibernate.id.enhanced.TableGenerator.TABLE_PARAM,
				tableGeneratorAnnotation.table()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.pkColumnName() ) ) {
		definitionBuilder.addParam(
				org.hibernate.id.enhanced.TableGenerator.SEGMENT_COLUMN_PARAM,
				tableGeneratorAnnotation.pkColumnName()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.pkColumnValue() ) ) {
		definitionBuilder.addParam(
				org.hibernate.id.enhanced.TableGenerator.SEGMENT_VALUE_PARAM,
				tableGeneratorAnnotation.pkColumnValue()
		);
	}
	if ( !BinderHelper.isEmptyAnnotationValue( tableGeneratorAnnotation.valueColumnName() ) ) {
		definitionBuilder.addParam(
				org.hibernate.id.enhanced.TableGenerator.VALUE_COLUMN_PARAM,
				tableGeneratorAnnotation.valueColumnName()
		);
	}
	definitionBuilder.addParam(
			org.hibernate.id.enhanced.TableGenerator.INCREMENT_PARAM,
			String.valueOf( tableGeneratorAnnotation.allocationSize() )
	);
	// See comment on HHH-4884 wrt initialValue.  Basically initialValue is really the stated value + 1
	definitionBuilder.addParam(
			org.hibernate.id.enhanced.TableGenerator.INITIAL_PARAM,
			String.valueOf( tableGeneratorAnnotation.initialValue() + 1 )
	);

	// TODO : implement unique-constraint support
	if ( tableGeneratorAnnotation.uniqueConstraints() != null
			&& tableGeneratorAnnotation.uniqueConstraints().length > 0 ) {
		log.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() );
	}
}