I posted to Broadleaf Commerce because they also needed PersistentClass
:
I've been tooling with Hibernate 5, and some of these changes ....
To get metadata now use the Serviceloader:
package org.broadleafcommerce.openadmin.server.dao;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderFactory;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;
public class EntityMetaData implements SessionFactoryBuilderFactory {
private static final ThreadLocal<MetadataImplementor> meta = new ThreadLocal<>();
@Override
public SessionFactoryBuilder getSessionFactoryBuilder(MetadataImplementor metadata, SessionFactoryBuilderImplementor defaultBuilder) {
meta.set(metadata);
return defaultBuilder;
}
public static MetadataImplementor getMeta() {
return meta.get();
}
}
You will need the file:
/resources/META-INF/services/org.hibernate.boot.spi.SessionFactoryBuilderFactory
with the fully qualified class name, which in my example is:
org.broadleafcommerce.openadmin.server.dao.EntityMetaData
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…