+ /**
+ * Change class-loader of current thread.
+ * This is necessary, because still not all parts of Hibernate 5 use
+ * the newly introduced ClassLoaderService and will fail otherwise!
+ */
+ Thread thread = Thread.currentThread();
+ ClassLoader contextClassLoader = thread.getContextClassLoader();
+ try
+ {
+ thread.setContextClassLoader(classLoader);
+ build((MetadataImplementor)metadataBuilder.build());
+ }
+ finally
+ {
+ thread.setContextClassLoader(contextClassLoader);
+ }