org.hibernate.id.SequenceGenerator Java Examples

The following examples show how to use org.hibernate.id.SequenceGenerator. 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: DefaultIdentifierGeneratorFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
	this.serviceRegistry = serviceRegistry;
	this.dialect = serviceRegistry.getService( JdbcEnvironment.class ).getDialect();
	final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );

	final boolean useNewIdentifierGenerators = configService.getSetting(
			AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS,
			StandardConverters.BOOLEAN,
			true
	);

	if(!useNewIdentifierGenerators) {
		register( "sequence", SequenceGenerator.class );
	}
}
 
Example #2
Source File: ReactiveIdentifierGeneratorFactory.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static IdentifierGenerator augmentWithReactiveGenerator(IdentifierGenerator generator, Type type, Properties params, ServiceRegistryImplementor serviceRegistry) {
	ReactiveIdentifierGenerator<?> reactiveGenerator;
	if (generator instanceof SequenceStyleGenerator) {
		DatabaseStructure structure = ((SequenceStyleGenerator) generator).getDatabaseStructure();
		if (structure instanceof TableStructure) {
			reactiveGenerator = new TableReactiveIdentifierGenerator(true);
		}
		else if (structure instanceof SequenceStructure) {
			reactiveGenerator = new SequenceReactiveIdentifierGenerator();
		}
		else {
			throw new IllegalStateException("unknown structure type");
		}
	}
	else if (generator instanceof TableGenerator) {
		reactiveGenerator = new TableReactiveIdentifierGenerator(false);
	}
	else if (generator instanceof SequenceGenerator) {
		reactiveGenerator = new SequenceReactiveIdentifierGenerator();
	}
	else if (generator instanceof SelectGenerator) {
		//TODO: this is easy to fix!
		throw new HibernateException("SelectGenerator is not yet supported in Hibernate Reactive");
	}
	else {
		//nothing to do
		return generator;
	}

	((Configurable) reactiveGenerator).configure( type, params, serviceRegistry );

	return new ReactiveGeneratorWrapper<>( reactiveGenerator, generator );
}
 
Example #3
Source File: GrailsIdentifierGeneratorFactory.java    From gorm-hibernate5 with Apache License 2.0 5 votes vote down vote up
@Override
public Class getIdentifierGeneratorClass(String strategy) {
    Class generatorClass = super.getIdentifierGeneratorClass(strategy);
    if("native".equals(strategy) && generatorClass == SequenceGenerator.class) {
        generatorClass = super.getIdentifierGeneratorClass("sequence-identity");
    }
    return generatorClass;
}
 
Example #4
Source File: Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * The class (which implements {@link org.hibernate.id.IdentifierGenerator})
 * which acts as this dialects native generation strategy.
 * <p/>
 * Comes into play whenever the user specifies the native generator.
 *
 * @return The native generator class.
 */
public Class getNativeIdentifierGeneratorClass() {
	if ( supportsIdentityColumns() ) {
		return IdentityGenerator.class;
	}
	else if ( supportsSequences() ) {
		return SequenceGenerator.class;
	}
	else {
		return TableHiLoGenerator.class;
	}
}
 
Example #5
Source File: PostgreSQLDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Class getNativeIdentifierGeneratorClass() {
	return SequenceGenerator.class;
}
 
Example #6
Source File: HqlSqlWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static boolean supportsIdGenWithBulkInsertion(IdentifierGenerator generator) {
	return SequenceGenerator.class.isAssignableFrom( generator.getClass() )
	        || PostInsertIdentifierGenerator.class.isAssignableFrom( generator.getClass() );
}