After Migration from 4.1.19 to 5.2.17 we got
org.hibernate.UnknownEntityTypeException: Unable to locate persister:
when calling
Session.get(Class clazz, Serializable id)
We don’t use Hibernate/JPA-Annotations. We still use legacy HBM mapping-files.
Here’s what the Initialization-Method for the SessionFactory looks like:
private synchronized SessionFactory getSessionFactory() {
private SessionFactory sessionFactory;
try {
// Create configuration
Configuration configuration = new Configuration();
// add custom-Hibernate-Interceptor
configuration.setInterceptor(new myInterceptor());
// Build a Service-Registry
aServiceRegistry = new StandardServiceRegistryBuilder(bootstrapRegistry)
.applySettings(configuration.getProperties())
.configure()
.build();
// Build the MetadataSources
MetadataSources aSources = new MetadataSources(aServiceRegistry);
// Build the Metadata
Metadata metadata = aSources.getMetadataBuilder().build();
// Build the SessionFactory
sessionFactory = metadata.getSessionFactoryBuilder().build();
}
catch (Throwable ex) {
....
}
return sessionFactory;
}