Top Description Inners Fields Constructors Methods
org.hibernate.id.enhanced

public Class PooledOptimizer

extends AbstractOptimizer
implements InitialValueAwareOptimizer
Class Inheritance
All Implemented Interfaces
org.hibernate.id.enhanced.InitialValueAwareOptimizer
Imports
java.io.Serializable, java.util.Map, java.util.concurrent.ConcurrentHashMap, org.hibernate.HibernateException, org.hibernate.id.IntegralDataTypeHolder, org.hibernate.internal.CoreMessageLogger, org.jboss.logging.Logger

Optimizer which uses a pool of values, storing the next low value of the range in the database.

Note that this optimizer works essentially the same as the org.hibernate.id.enhanced.HiLoOptimizer except that here the bucket ranges are actually encoded into the database structures.

Note if you prefer that the database value be interpreted as the bottom end of our current range, then use the PooledLoOptimizer strategy

Author
Steve Ebersole
See Also
PooledLoOptimizer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private long
private static final CoreMessageLogger
private PooledOptimizer.GenerationState
private Map<String, PooledOptimizer.GenerationState>
Inherited from org.hibernate.id.enhanced.AbstractOptimizer:
incrementSizereturnClass

Constructor Summary

AccessConstructor and Description
public
PooledOptimizer(Class<T>
The Java type of the values to be generated
returnClass
,
int
The increment size.
incrementSize
)

Constructs a PooledOptimizer

Method Summary

Modifier and TypeMethod and Description
public boolean
applyIncrementSizeToSourceValues()

Implements org.hibernate.id.enhanced.Optimizer.applyIncrementSizeToSourceValues.

Are increments to be applied to the values stored in the underlying value source?
public synchronized Serializable
generate(AccessCallback
Callback to access the underlying value source.
callback
)

Implements org.hibernate.id.enhanced.Optimizer.generate.

Generate an identifier value accounting for this specific optimization.
public IntegralDataTypeHolder
getLastSourceValue()

Implements org.hibernate.id.enhanced.Optimizer.getLastSourceValue.

A common means to access the last value obtained from the underlying source.
public IntegralDataTypeHolder

Returns:

Value for property 'lastValue'.
getLastValue
()

Getter for property 'lastValue'.

public void
injectInitialValue(long
The initial value specified by the user, or -1 to indicate that the user did not specify.
initialValue
)

Implements org.hibernate.id.enhanced.InitialValueAwareOptimizer.injectInitialValue.

Reports the user specified initial value to the optimizer.
private PooledOptimizer.GenerationState
locateGenerationState(String tenantIdentifier)

private PooledOptimizer.GenerationState
Inherited from org.hibernate.id.enhanced.AbstractOptimizer:
getIncrementSizegetReturnClass

Field Detail

initialValueback to summary
private long initialValue
logback to summary
private static final CoreMessageLogger log
noTenantStateback to summary
private PooledOptimizer.GenerationState noTenantState
tenantSpecificStateback to summary
private Map<String, PooledOptimizer.GenerationState> tenantSpecificState

Constructor Detail

PooledOptimizerback to summary
public PooledOptimizer(Class<T> returnClass, int incrementSize)

Constructs a PooledOptimizer

Parameters
returnClass:Class<T>

The Java type of the values to be generated

incrementSize:int

The increment size.

Method Detail

applyIncrementSizeToSourceValuesback to summary
public boolean applyIncrementSizeToSourceValues()

Implements org.hibernate.id.enhanced.Optimizer.applyIncrementSizeToSourceValues.

Doc from org.hibernate.id.enhanced.Optimizer.applyIncrementSizeToSourceValues.

Are increments to be applied to the values stored in the underlying value source?

Returns:boolean

True if the values in the source are to be incremented according to the defined increment size; false otherwise, in which case the increment is totally an in memory construct.

Annotations
@Override
generateback to summary
public synchronized Serializable generate(AccessCallback callback)

Implements org.hibernate.id.enhanced.Optimizer.generate.

Doc from org.hibernate.id.enhanced.Optimizer.generate.

Generate an identifier value accounting for this specific optimization. All known implementors are synchronized. Consider carefully if a new implementation could drop this requirement.

Parameters
callback:AccessCallback

Callback to access the underlying value source.

Returns:Serializable

The generated identifier value.

Annotations
@Override
getLastSourceValueback to summary
public IntegralDataTypeHolder getLastSourceValue()

Implements org.hibernate.id.enhanced.Optimizer.getLastSourceValue.

Doc from org.hibernate.id.enhanced.Optimizer.getLastSourceValue.

A common means to access the last value obtained from the underlying source. This is intended for testing purposes, since accessing the underlying database source directly is much more difficult.

Returns:IntegralDataTypeHolder

The last value we obtained from the underlying source; null indicates we have not yet consulted with the source.

Annotations
@Override
getLastValueback to summary
public IntegralDataTypeHolder getLastValue()

Getter for property 'lastValue'.

Exposure intended for testing purposes.

Returns:IntegralDataTypeHolder

Value for property 'lastValue'.

injectInitialValueback to summary
public void injectInitialValue(long initialValue)

Implements org.hibernate.id.enhanced.InitialValueAwareOptimizer.injectInitialValue.

Doc from org.hibernate.id.enhanced.InitialValueAwareOptimizer.injectInitialValue.

Reports the user specified initial value to the optimizer.

-1 is used to indicate that the user did not specify.

Parameters
initialValue:long

The initial value specified by the user, or -1 to indicate that the user did not specify.

Annotations
@Override
locateGenerationStateback to summary
private PooledOptimizer.GenerationState locateGenerationState(String tenantIdentifier)
noTenantGenerationStateback to summary
private PooledOptimizer.GenerationState noTenantGenerationState()
org.hibernate.id.enhanced back to summary

private Class PooledOptimizer.GenerationState

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private IntegralDataTypeHolder
private IntegralDataTypeHolder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hiValueback to summary
private IntegralDataTypeHolder hiValue
valueback to summary
private IntegralDataTypeHolder value

Constructor Detail

GenerationStateback to summary
private GenerationState()