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

Consider upgrade to Hibernate ORM 5.2 #6111

Closed
Polve opened this issue Jun 2, 2016 · 18 comments
Closed

Consider upgrade to Hibernate ORM 5.2 #6111

Polve opened this issue Jun 2, 2016 · 18 comments
Assignees
Labels
type: blocker An issue that is blocking us from releasing
Milestone

Comments

@Polve
Copy link

Polve commented Jun 2, 2016

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 2, 2016
@philwebb philwebb added type: blocker An issue that is blocking us from releasing and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 6, 2016
@philwebb philwebb added this to the 1.4.0.RC1 milestone Jun 6, 2016
@philwebb
Copy link
Member

philwebb commented Jun 6, 2016

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.

@philwebb philwebb changed the title Upgrade to Hibernate ORM 5.2 Consider upgrade to Hibernate ORM 5.2 Jun 6, 2016
@rakpan
Copy link

rakpan commented Jun 7, 2016

Are we raising the bar for spring boot too?

@philwebb
Copy link
Member

philwebb commented Jun 7, 2016

@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.

@snicoll
Copy link
Member

snicoll commented Jun 9, 2016

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

@snicoll snicoll self-assigned this Jun 9, 2016
@philwebb
Copy link
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.

@snicoll
Copy link
Member

snicoll commented Jun 10, 2016

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

@philwebb
Copy link
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.

@ghost
Copy link

ghost commented Jun 10, 2016

My approach to use hibernate 5.2 right now would be

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>

@wilkinsona
Copy link
Member

wilkinsona commented Jun 15, 2016

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.

@snicoll
Copy link
Member

snicoll commented Jun 15, 2016

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

snicoll added a commit to snicoll/spring-boot that referenced this issue Jun 16, 2016
snicoll added a commit that referenced this issue Jun 17, 2016
@snicoll
Copy link
Member

snicoll commented Jun 17, 2016

Fixed in 2ff9e3c

@snicoll snicoll closed this as completed Jun 17, 2016
@ceefour
Copy link
Contributor

ceefour commented Jul 30, 2016

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.

@snicoll
Copy link
Member

snicoll commented Jul 30, 2016

@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.

@ceefour
Copy link
Contributor

ceefour commented Jul 30, 2016

@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...

@snicoll
Copy link
Member

snicoll commented Jul 30, 2016

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.

@ceefour
Copy link
Contributor

ceefour commented Jul 30, 2016

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.

@snicoll
Copy link
Member

snicoll commented Jul 31, 2016

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

@ceefour
Copy link
Contributor

ceefour commented Jul 31, 2016

@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
Labels
type: blocker An issue that is blocking us from releasing
Projects
None yet
Development

No branches or pull requests

7 participants