user3133300
user3133300

Reputation: 627

How do I upgrade Hibernate 4.3 --> 5.2?

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.

Upvotes: 9

Views: 12464

Answers (2)

peach7
peach7

Reputation: 1

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();

Upvotes: 0

peach
peach

Reputation: 757

The full Hibernate ORM Upgrade Guide can be found here:

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

Upvotes: 11

Related Questions