Skip to content

Consider upgrade to Hibernate ORM 5.2 #6111

Closed

Description

@Polve

Hibernate 5.2 is now GA and it might be nice to upgrade as part of Spring Boot 1.4.

Activity

  1. added
    status: waiting-for-triage
    on Jun 2, 2016
  2. added
    type: blocker
    and removed
    status: waiting-for-triage
    on Jun 6, 2016
  3. added this to the 1.4.0.RC1 milestone on Jun 6, 2016
  4. philwebb commented on Jun 6, 2016

    @philwebb
    Member

    A lot of things have changed between 5.1 and 5.2 (Java 8 minimum requirement being the most concerning). Ideally it would be good to get this into Spring Boot 1.4 as people will be upgrading from Hibernate 4.x and it would be nice to get all the pain out of the way in one hit.

  5. changed the title [-]Upgrade to Hibernate ORM 5.2[/-] [+]Consider upgrade to Hibernate ORM 5.2[/+] on Jun 6, 2016
  6. rakpan commented on Jun 7, 2016

    @rakpan

    Are we raising the bar for spring boot too?

  7. philwebb commented on Jun 7, 2016

    @philwebb
    Member

    @rakpan Not until Spring Boot 2.0. However, we could still consider Hibernate 5.2 as our default choice as long as people can easily downgrade.

  8. snicoll commented on Jun 9, 2016

    @snicoll
    Member

    Considering that hibernate-entitymanager is gone in 5.2, switching to 5.2 effectively means that 5.2 is our bare minimum since it changes the pom structure. I'd argue 5.2.1 should restore that artifact (even if it's empty) for backward compatible reason.

    @philwebb I had a quick look and the "as long as people can easily downgrade" does not seem possible at the moment.

    I've raised HHH-10823

  9. self-assigned this
    on Jun 9, 2016
  10. philwebb commented on Jun 10, 2016

    @philwebb
    Member

    @snicoll Unless I'm missing something, I'm not sure I agree. Users might not be able to downgrade with a single property but they could set the property and add back hibernate-entitymanager.

  11. snicoll commented on Jun 10, 2016

    @snicoll
    Member

    Yes. I don't consider that as "easy".

  12. philwebb commented on Jun 10, 2016

    @philwebb
    Member

    @snicoll It's not super easy, but it's not that hard and it's probably less confusing that having an empty hibernate-entitymanager project that doesn't contain anything.

  13. wilkinsona commented on Jun 15, 2016

    @wilkinsona
    Member

    Spring Framework 4.3.0.RELEASE isn't fully compatible with Hibernate 5.1 (see SPR-14365) so we either need to move to 5.2 or wait for Spring Framework 4.3.1.RELEASE.

  14. snicoll commented on Jun 15, 2016

    @snicoll
    Member

    Indeed, that probably means that our RC1 has to wait for 4.3.1.RELEASE

  15. added 2 commits that reference this issue on Jun 16, 2016
  16. snicoll commented on Jun 17, 2016

    @snicoll
    Member

    Fixed in 2ff9e3c

  17. ceefour commented on Jul 30, 2016

    @ceefour
    Contributor

    I'd 👍 not for "requiring" 5.2 but at least allowing people to use Hibernate 5.2 if they want.
    Currently when I used hibernate-core and hibernate-spatial 5.2.1.Final, with Spring Boot 1.4.0, I got:

    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/bytecode/instrumentation/internal/FieldInterceptionHelper
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
        at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:535)
        at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
        at com.satukancinta.DaemonApp.main(DaemonApp.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/bytecode/instrumentation/internal/FieldInterceptionHelper
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:199)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
        ... 16 common frames omitted
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/bytecode/instrumentation/internal/FieldInterceptionHelper
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:536)
        at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1192)
        at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.getCustomizers(EmbeddedServletContainerCustomizerBeanPostProcessor.java:77)
        at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
        at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        ... 24 common frames omitted
    Caused by: java.lang.NoClassDefFoundError: org/hibernate/bytecode/instrumentation/internal/FieldInterceptionHelper
        at org.hibernate.jpa.internal.util.PersistenceUtilHelper.isLoadedWithoutReference(PersistenceUtilHelper.java:121)
        at org.hibernate.jpa.HibernatePersistenceProvider$1.isLoadedWithoutReference(HibernatePersistenceProvider.java:171)
        at javax.persistence.Persistence$1.isLoaded(Persistence.java:111)
        at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:46)
        at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:128)
        at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:36)
        at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1612)
        at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1597)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:609)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:580)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:524)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:492)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:457)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:407)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:205)
        at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:93)
        at org.springframework.validation.DataBinder.validate(DataBinder.java:852)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.validate(PropertiesConfigurationFactory.java:355)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:276)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:245)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:346)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:302)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        ... 37 common frames omitted
    Caused by: java.lang.ClassNotFoundException: org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 62 common frames omitted
    

    While I'm ok with Spring Boot not defaulting to Hibernate 5.2, it concerns me that users can't use Hibernate 5.2 or even 5.3.

  18. snicoll commented on Jul 30, 2016

    @snicoll
    Member

    @ceefour this issue is closed. If you believe you have found an issue in Spring Boot, please create a dedicated issue. Before you do, try your app without hibernate-spatial. Maybe that release hasn't been aligned with Hibernate 4.2.1.Final yet? We have a sample that works with Hibernate 4.2.

  19. ceefour commented on Jul 30, 2016

    @ceefour
    Contributor

    @snicoll We have no issue with Hibernate 4.2 and Hibernate 5.0 (both Spring Boot 1.3.6 and 1.4.0), just Boot 1.4.0 (Spring v4.3.2.RELEASE) with Hibernate 5.2.1.Final.

    Removing hibernate-spatial doesn't remove the problem.

    Should I file the issue on Spring-boot or JIRA Spring ORM ?

    Spring 4.3 claims it supports Hibernate 4.2 (https://jira.spring.io/browse/SPR-14327) so I'm not sure whether this is Boot's or Spring's...

  20. snicoll commented on Jul 30, 2016

    @snicoll
    Member

    Sorry, I mixed up. I meant 5.2.1.Final. We have a sample so I don't know where the problem is but it might be in your app.

  21. ceefour commented on Jul 30, 2016

    @ceefour
    Contributor

    Thanks @snicoll , I've found the issue. It's had I still loaded hibernate-entitymanager 5.0.9.Final, which to fix it in my project requires:

    <dependency>
        <groupId>org.jadira.usertype</groupId>
        <artifactId>usertype.core</artifactId>
        <version>5.0.0.GA</version>
        <!-- usertype 5.0.0 not yet compatible with Hibernate 5.2: https://github.com/JadiraOrg/jadira/pull/57 -->
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <!-- hibernate-entitymanager must be excluded: https://github.com/spring-projects/spring-boot/issues/6111#issuecomment-225074425 -->
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    However, usertype's compatibility with Hibernate 5.2 is another issue (JadiraOrg/jadira#57).

    It's nice that the Spring Boot documentation has been updated to refer to the Hibernate 5.2 sample, however I'd say it's a good idea to signify in the documentation that especially the exclusion of hibernate-entitymanager is strictly required. The Hibernate 5.2 sample's pom.xml has no information at all on why hibernate-entitymanager was excluded. So users can be frustrated for some time before finding this page which explains the background of issue.

  22. snicoll commented on Jul 31, 2016

    @snicoll
    Member

    @ceefour could you please stop commenting on closed issues please?

  23. ceefour commented on Jul 31, 2016

    @ceefour
    Contributor

    @snicoll Sorry, this would be my last comment on this thread. I did the comment because this page is high on Google, so if someone else is having the same problem as I am, I hope that by commenting, it can lead them to the solution (instead of being even more confused, as it was in my case). It happens a lot to me, and I'm thankful for people "leaving a trail" of problem solving. I know this is not StackOverflow though, I'm sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: blocker

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions