Skip to content

set spring.jpa.properties.hibernate.id.new_generator_mappings=true by default #7612

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

Closed
xenoterracide opened this issue Dec 9, 2016 · 11 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@xenoterracide
Copy link
Contributor

Hibernate has a tendency to throw these warnings in Hibernate 5

[WARN ] [11:58:26] [localhost-startStop-1] orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.

setting spring.jpa.properties.hibernate.id.new_generator_mappings=true will stop it and is good for new projects, and I believe fine for old projects in most cases. I believe this should be the default in the next major version of Spring Boot's autoconfig, and probably called out in upgrade documentation.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 9, 2016
@philwebb philwebb modified the milestones: 2.0.0, 2.0.0.M1 Jan 10, 2017
@philwebb philwebb added priority: normal type: enhancement A general enhancement and removed for: team-meeting status: waiting-for-triage An issue we've not yet triaged labels Jan 10, 2017
@philwebb philwebb modified the milestones: 2.0.0.M1, 2.0.0 Jan 12, 2017
@mbhave mbhave self-assigned this Mar 24, 2017
@mbhave mbhave closed this as completed in 735dbc4 Mar 24, 2017
@wilkinsona
Copy link
Member

I think this change has broken DataJpaTestIntegrationTests testEntityManagerPersistAndGetId

@mbhave
Copy link
Contributor

mbhave commented Mar 24, 2017

@wilkinsona was about to fix it by adding this.entities.flush() but I guess this works too.

@wilkinsona
Copy link
Member

That might be better, I don't know really. Feel free to change it to call flush() if you prefer.

@mbhave
Copy link
Contributor

mbhave commented Mar 24, 2017

Reopening to fix the SampleDataJpaApplicationTests and SampleJpaApplicationTests

@mbhave
Copy link
Contributor

mbhave commented Mar 25, 2017

Reverting the change for now till we figure out what the best way to fix the tests is.

@mbhave mbhave closed this as completed in b13641e Apr 25, 2017
mbhave added a commit that referenced this issue Apr 25, 2017
@philwebb philwebb reopened this Apr 27, 2017
@philwebb
Copy link
Member

I wonder if we should add the spring.jpa.hibernate.use-new-id-generator-mappings=false property to application.properties? I have a feeling that the samples now won't run outside of the tests.

The other option is we look at somehow updating the insert.sql file to trigger the new sequence generators.

@mbhave
Copy link
Contributor

mbhave commented Apr 27, 2017

you're right, I'll give updating import.sql a shot.

@snicoll
Copy link
Member

snicoll commented May 11, 2017

It looks like the flyway sample is failing but the build doesn't. Could it be related to this issue?

@mbhave
Copy link
Contributor

mbhave commented May 11, 2017

yes I believe it is. I have a fix for it on this here. I wasn't totally sure about the best way to fix the samples, so waiting for a review to merge it in.

@mbhave mbhave closed this as completed in dc7b3f6 May 12, 2017
Zemke added a commit to cwt-wa/cwt that referenced this issue Oct 9, 2017
Data has been migrated from MySQL and IDs are assigned not matching how
Hibernate generates sequences for new IDs. This leads to colliding IDs.

https://stackoverflow.com/a/21948674
spring-projects/spring-boot#7612 (comment)
@LaurenceMommers
Copy link

LaurenceMommers commented Nov 17, 2017

Currently the documentation still states that the property defaults to false for backwards compatibility.
This change also leads to some weird behavior where by default a sequence table is used in mysql instead of the autoIncrement feature HHH-11014

line 181 of JpaProperties.java

/**

  • Use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. This is
  • actually a shortcut for the "hibernate.id.new_generator_mappings" property.
  • When not specified will default to "false" for backwards compatibility.
    */

@wilkinsona
Copy link
Member

Thanks for spotting that, @LaurenceMommers. I've opened #11064.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants