Skip to content

Commit fd9c84f

Browse files
committed
improve javadoc of "pooled" optimizers
1 parent 76b35f0 commit fd9c84f

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledLoOptimizer.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@
1717
import java.util.concurrent.locks.ReentrantLock;
1818

1919
/**
20-
* Variation of {@link PooledOptimizer} which interprets the incoming database
21-
* value as the lo value, rather than the hi value.
20+
* Optimizer which uses a pool of values, backed by a <em>logical sequence</em>.
21+
* A logical sequence is usually just an unpooled sequence or table generator.
22+
* <p>
23+
* The pool size is controlled by the {@code allocationSize} of a
24+
* {@linkplain jakarta.persistence.SequenceGenerator sequence generator} or
25+
* {@linkplain jakarta.persistence.TableGenerator sequence generator}.
26+
* <p>
27+
* From time to time, the optimizer allocates a range of values to itself,
28+
* interpreting the next value retrieved from the logical sequence as the
29+
* lower bound on the range of newly allocated ids. Thus, the generated ids
30+
* begin with the value retrieved from the logical sequence.
31+
* <p>
32+
* The {@link PooledOptimizer} is similar, but interprets the current value
33+
* of the logical sequence as an upper bound on the range of already-allocated
34+
* ids.
2235
*
2336
* @author Steve Ebersole
2437
*
2538
* @see PooledOptimizer
39+
* @see jakarta.persistence.SequenceGenerator#allocationSize
40+
* @see jakarta.persistence.TableGenerator#allocationSize
2641
*/
2742
public class PooledLoOptimizer extends AbstractOptimizer {
2843

hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledOptimizer.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,33 @@
2020
import java.util.concurrent.locks.ReentrantLock;
2121

2222
/**
23-
* Optimizer which uses a pool of values, storing the next low value of the range
24-
* in the database.
23+
* Optimizer which uses a pool of values, backed by a <em>logical sequence</em>.
24+
* A logical sequence is usually just an unpooled sequence or table generator.
2525
* <p>
26-
* This optimizer works essentially the same as the {@link HiLoOptimizer}, except
27-
* that here the bucket ranges are actually encoded into the database structures.
26+
* The pool size is controlled by the {@code allocationSize} of a
27+
* {@linkplain jakarta.persistence.SequenceGenerator sequence generator} or
28+
* {@linkplain jakarta.persistence.TableGenerator sequence generator}.
2829
* <p>
29-
* If you prefer that the database value be interpreted as the bottom end of our
30-
* current range, then use the {@link PooledLoOptimizer} strategy.
30+
* This optimizer interprets the current value held by its underlying logical
31+
* sequence (that is, the last value generated by a database sequence, or the
32+
* current value of a table row emulating a sequence) as an upper bound on the
33+
* range of already-allocated ids. From time to time, the optimizer allocates
34+
* a range of values to itself, interpreting the next value retrieved from the
35+
* logical sequence as an upper bound on the range of newly allocated ids.
36+
* <p>
37+
* The {@link PooledLoOptimizer} is similar, but interprets the current value
38+
* of the logical sequence as a lower bound on the range of already-allocated
39+
* ids.
40+
* <p>
41+
* This optimizer has similar performance characteristics to the
42+
* {@link HiLoOptimizer}, but here the range bounds are stored directly by the
43+
* underlying database structures.
3144
*
3245
* @author Steve Ebersole
3346
*
3447
* @see PooledLoOptimizer
48+
* @see jakarta.persistence.SequenceGenerator#allocationSize
49+
* @see jakarta.persistence.TableGenerator#allocationSize
3550
*/
3651
public class PooledOptimizer extends AbstractOptimizer implements InitialValueAwareOptimizer {
3752

0 commit comments

Comments
 (0)