Example usage for org.hibernate.boot.spi MetadataBuildingContext getBuildingOptions

List of usage examples for org.hibernate.boot.spi MetadataBuildingContext getBuildingOptions

Introduction

In this page you can find the example usage for org.hibernate.boot.spi MetadataBuildingContext getBuildingOptions.

Prototype

MetadataBuildingOptions getBuildingOptions();

Source Link

Document

Access to the options specified by the org.hibernate.boot.MetadataBuilder

Usage

From source file:com.blazebit.persistence.integration.hibernate.Hibernate52MetadataContributor.java

License:Apache License

private void addEntity(String className, MetadataBuildingContext metadataBuildingContext) {
    try {//w w  w .  j a  v a  2 s . c  o  m
        MetadataBuildingOptions options = metadataBuildingContext.getBuildingOptions();
        Object /*ReflectionManager*/ reflectionManager = MetadataBuildingOptions.class
                .getMethod("getReflectionManager").invoke(options);
        //            Object /*XClass*/ clazz = reflectionManager.classForName(className);
        Method classForName = reflectionManager.getClass().getMethod("classForName", String.class);
        Object /*XClass*/ clazz = classForName.invoke(reflectionManager, className);
        Map<Object /*XClass*/, InheritanceState> inheritanceStatePerClass = new HashMap<Object /*XClass*/, InheritanceState>(
                1);

        //        InheritanceState state = new InheritanceState(clazz, inheritanceStatePerClass, metadataBuildingContext);
        InheritanceState state = InheritanceState.class
                .getConstructor(classForName.getReturnType(), Map.class, MetadataBuildingContext.class)
                .newInstance(clazz, inheritanceStatePerClass, metadataBuildingContext);

        inheritanceStatePerClass.put(clazz, state);

        //        AnnotationBinder.bindClass(clazz, inheritanceStatePerClass, metadataBuildingContext);
        AnnotationBinder.class
                .getMethod("bindClass", classForName.getReturnType(), Map.class, MetadataBuildingContext.class)
                .invoke(null, clazz, inheritanceStatePerClass, metadataBuildingContext);
    } catch (RuntimeException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new RuntimeException("Could not add entity", ex);
    }
}