How do I upgrade Hibernate 4.3 --> 5.2?
Asked Answered
L

2

9

I Googled around but don't see any tutorials for upgrading Hibernate to 5.2.

The only thing I could find was this: http://hibernate.org/search/documentation/migrate/5.0/ but it seems to specific to Hibernate search.

Limey answered 18/6, 2018 at 12:18 Comment(1)
Possible duplicate of How to upgrade Hibernate from version 4.3 to 5.2 for migration to JDK 10?Gavel
T
11

The full Hibernate ORM Upgrade Guide can be found here:

https://github.com/hibernate/hibernate-orm/blob/5.0/migration-guide.adoc

Tarver answered 18/6, 2018 at 15:29 Comment(5)
But where do I actually change the version number?Limey
which version number? what are you using? gradle? spring boot? Please ask answers that can actually be answered :)Tarver
The Hibernate version number. Thanks for answering, btw :)Limey
what are you using? gradle? spring boot? Please ask concrete questions with all the info needed in order to answer. in case you are using spring boot with gradle and want to override the version you can find it in the Spring Docs: ext['hibernate.version'] = '5.2.12.Final' for Hibernate with Gradle/hibernate directly see the Hibernate Docs ``Tarver
Yup! I'm using spring boot 1.3. I need to upgrade to spring boot 2.0, which requires Hibernate 5.2.Limey
L
0

Refer hibernate documentation: https://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#bootstrap-jpa

Section 3.2) native bootstrapping might be helpful, as it was in my case during migration

config = new Configuration().configure("hibernate.cfg.xml");
config.addProperties(hibernateProperties);

BootstrapServiceRegistry bootstrapServiceRegistry = new BootstrapServiceRegistryBuilder()
    .build();

StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder(bootstrapServiceRegistry);

standardServiceRegistryBuilder.applySettings(config.getProperties());

StandardServiceRegistry standardServiceRegistry = standardServiceRegistryBuilder
    .configure()
    .build();

MetadataSources metadataSources = new MetadataSources(standardServiceRegistry);
metadataSources.addPackage(packageWithMappedClasses);

Metadata metadata = metadataSources.buildMetadata();
sessionFactory = metadata.buildSessionFactory();
Liaotung answered 11/3 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.