我用 Google 搜索了一下,但没有看到任何将 Hibernate 升级到 5.2 的教程。
我唯一能找到的是: http://hibernate.org/search/documentation/migrate/5.0/ 但它似乎特定于 Hibernate 搜索。
完整的 Hibernate ORM 升级指南可以在这里找到:
https://github.com/hibernate/hibernate-orm/blob/5.0/migration-guide.adoc
第 3.2 节)本机引导可能会有所帮助,就像我在迁移期间的情况一样
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();