Skip to content
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

Hypersistentence Optimizer reports an issue marked as blocker #2204

Open
ecruz165 opened this issue Feb 8, 2023 · 3 comments · May be fixed by #2220
Open

Hypersistentence Optimizer reports an issue marked as blocker #2204

ecruz165 opened this issue Feb 8, 2023 · 3 comments · May be fixed by #2220

Comments

@ecruz165
Copy link
Contributor

ecruz165 commented Feb 8, 2023

Expected behavior

No issues should be listed as blocker.

Actual behavior

When analysis application with Hypersisitance Optimizer, it points out the following:
BLOCKER - PooledSequenceOptimizerEvent - You should set the [hibernate.id.new_generator_mappings] configuration property to the value of [true], as Hibernate can then use the pooled or pooled-lo identifier optimizers for sequence-based entity identifiers. Note that the pooled and pooled-lo optimizers are not backward compatible with the legacy hilo optimizer that you might have used with Hibernate ORM 3 or 4. So, if you were using the hilo optimizer, then you would need to increase the current sequence number so that is greater than any previously allocated entity identifiers. For more info about this event, check out this User Guide link - https://vladmihalcea.com/hypersistence-optimizer/docs/user-guide/#PooledSequenceOptimizerEvent

Steps to reproduce behavior

Run analysis with Hypersisitance Optimizer against a application test that uses SportBootTest that application

@ecruz165
Copy link
Contributor Author

ecruz165 commented Feb 8, 2023

@chrisknoll I believe it is seeing the following in DataAccessConfig and suggest it be set to true.

    private Properties getJPAProperties() {
* *. * code removed for brevity * * *
this.env.getProperty("spring.jpa.properties.hibernate.order_inserts"));
        properties.setProperty(**"hibernate.id.new_generator_mappings", "false"**);
        return properties;
    }

Setting this to true sets the hibernate strategy to leverage org.hibernate.id.enhanced.SequenceStyleGenerator which i see is set for each Generator defined in code base. So this might be a false positive since you are using SequenceStyleGenerator everywhere. Updating the above to removes the issue from being raised in Hypersistence Optimizer report.

    private Properties getJPAProperties() {
  --- code removed for brevity ----
this.env.getProperty("spring.jpa.properties.hibernate.order_inserts"));
        properties.setProperty(**"hibernate.id.new_generator_mappings", "true"**);
        return properties;
    }

@ecruz165 ecruz165 changed the title Hypersistentence Reports an issue marked as blocker Hypersistentence Optimizer Reports an issue marked as blocker Feb 8, 2023
@ecruz165 ecruz165 changed the title Hypersistentence Optimizer Reports an issue marked as blocker Hypersistentence Optimizer reports an issue marked as blocker Feb 8, 2023
@chrisknoll
Copy link
Collaborator

chrisknoll commented Feb 8, 2023

So, this commit what added that line. This was done in 2017, but is related to updating to hibernate 5.0.12.

I believe that this was necessary because of the information included in your report:

Note that the pooled and pooled-lo optimizers are not backward compatible with the legacy hilo optimizer that you might have used with Hibernate ORM 3 or 4.

I do recall something related with HiLo sequencers that were in use prior to moving completely to SequenceStyleGenerators, But that's going back over 5 years now. It's surprising that this is considered a blocker tho, I'm wondering if other elements in this report will be this strict.

Edit:
Yes, according to the original issue:

This will update Hibernate to 5.0.12, which will require some cleanup of our Entity definitions with respect to GeneratedValues(type=AUTO) annotations (will file separate issues to track this.)

Edit 2:
Yes, I found it here, discussed here, and then moved to full-fledged SequenceStyleGenerators here.

I suppose the positive finding here is that we captured the legacy of this code in github issues and PRs, so I'm glad we can find the reasons and history behind these changes.

@ecruz165
Copy link
Contributor Author

ecruz165 commented Feb 9, 2023

I'll submit PR for setting value to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Review Complete
Development

Successfully merging a pull request may close this issue.

2 participants