use of org.hibernate.metamodel.RepresentationMode in project hibernate-orm by hibernate.
the class Property method getPropertyAccessStrategy.
// todo : remove
public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException {
final PropertyAccessStrategy propertyAccessStrategy = getPropertyAccessStrategy();
if (propertyAccessStrategy != null) {
return propertyAccessStrategy;
}
String accessName = getPropertyAccessorName();
if (accessName == null) {
if (clazz == null || java.util.Map.class.equals(clazz)) {
accessName = "map";
} else {
accessName = "property";
}
}
final RepresentationMode representationMode = clazz == null || java.util.Map.class.equals(clazz) ? RepresentationMode.MAP : RepresentationMode.POJO;
return resolveServiceRegistry().getService(PropertyAccessStrategyResolver.class).resolvePropertyAccessStrategy(clazz, accessName, representationMode);
}
use of org.hibernate.metamodel.RepresentationMode in project hibernate-orm by hibernate.
the class ManagedTypeRepresentationResolverStandard method resolveStrategy.
@Override
public EmbeddableRepresentationStrategy resolveStrategy(Component bootDescriptor, Supplier<EmbeddableMappingType> runtimeDescriptorAccess, RuntimeModelCreationContext creationContext) {
// RepresentationMode representation = bootDescriptor.getExplicitRepresentationMode();
RepresentationMode representation = null;
if (representation == null) {
if (bootDescriptor.getComponentClassName() == null) {
representation = RepresentationMode.MAP;
} else {
representation = RepresentationMode.POJO;
}
}
final CompositeUserType<Object> compositeUserType;
if (bootDescriptor.getTypeName() != null) {
compositeUserType = (CompositeUserType<Object>) creationContext.getBootstrapContext().getServiceRegistry().getService(ManagedBeanRegistry.class).getBean(creationContext.getBootstrapContext().getClassLoaderAccess().classForName(bootDescriptor.getTypeName())).getBeanInstance();
} else {
compositeUserType = null;
}
final EmbeddableInstantiator customInstantiator;
if (bootDescriptor.getCustomInstantiator() != null) {
final Class<? extends EmbeddableInstantiator> customInstantiatorImpl = bootDescriptor.getCustomInstantiator();
customInstantiator = creationContext.getBootstrapContext().getServiceRegistry().getService(ManagedBeanRegistry.class).getBean(customInstantiatorImpl).getBeanInstance();
} else if (compositeUserType != null) {
customInstantiator = new EmbeddableCompositeUserTypeInstantiator(compositeUserType);
} else {
customInstantiator = null;
}
if (representation == RepresentationMode.MAP) {
return new EmbeddableRepresentationStrategyMap(bootDescriptor, runtimeDescriptorAccess, customInstantiator, creationContext);
} else {
// StandardPojoRepresentationStrategy
return new EmbeddableRepresentationStrategyPojo(bootDescriptor, runtimeDescriptorAccess, customInstantiator, compositeUserType, creationContext);
}
}
Aggregations