New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence generator starts at the wrong number #168
Comments
These three commits should have targeted #178. The commit message is incorrect |
@ktisdell unsure where the bug relies. This seems like it might be something out of our control. Any additional thoughts? |
Not sure. I assumed that since we implement the org.broadleafcommerce.common.persistence.IdOverrideTableGenerator, that it might be in this code. It just doesn't make sense that if we specify that a sequence should start at 1000, with a batch size of 50, that the first sequence generated is 950. If there's nothing that we can do about it, then we should document it. It's just something that I noticed and logged. |
Somewhere along the way, Hibernate changed their default behavior to use a high range for the segment value, rather than an lo (which is what you expected). Both are acceptable as long as you know what the behavior is. It can be left as the default, or switched (I suggest leaving it, since it’s Hibernate’s default behavior). The lo behavior can be achieved by editing persistence.xml. I did so by editing the persistence.xml in the core module of demosite as follows: <?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/web</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="hibernate.id.optimizer.pooled.prefer_lo" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="blSecurePU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/webSecure</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="hibernate.id.optimizer.pooled.prefer_lo" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="blCMSStorage" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/cmsStorage</non-jta-data-source>
<exclude-unlisted-classes/>
<properties>
<property name="hibernate.id.optimizer.pooled.prefer_lo" value="true"/>
</properties>
</persistence-unit>
</persistence> As a result, this is not a bug, but does deserve documentation. Another issue will be opened for this documentation enhancement. |
referencing the Hibernate issue where this was documented: https://hibernate.atlassian.net/browse/HHH-5218 |
Just adding a summary of the algorithm used by hibernate to generate the ID's using the default (high strategy) PooledOptimizer, given the record in the DB is "1000" for the entity before the app starts and the batch allocation size is set to "50"
Here is the actual PooledOptimizer class: Here is the actual PooledLoOptimizer class: |
Create refresh-mxd-layers.py
When the SEQUENCE_GENERATOR table is populated the actual starting point for generating values is some number less than that. For example for OrderImpl, if your starting point in SEQUENCE_GENERATOR is 1000, then the actual starting point is 950.
The text was updated successfully, but these errors were encountered: