use of org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributesMetadata in project hibernate-orm by hibernate.
the class AbstractEntityPersister method generateLazySelectStringsByFetchGroup.
protected Map<String, String> generateLazySelectStringsByFetchGroup() {
final BytecodeEnhancementMetadata enhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
if (!enhancementMetadata.isEnhancedForLazyLoading() || !enhancementMetadata.getLazyAttributesMetadata().hasLazyAttributes()) {
return Collections.emptyMap();
}
Map<String, String> result = new HashMap<>();
final LazyAttributesMetadata lazyAttributesMetadata = enhancementMetadata.getLazyAttributesMetadata();
for (String groupName : lazyAttributesMetadata.getFetchGroupNames()) {
HashSet tableNumbers = new HashSet();
ArrayList columnNumbers = new ArrayList();
ArrayList formulaNumbers = new ArrayList();
for (LazyAttributeDescriptor lazyAttributeDescriptor : lazyAttributesMetadata.getFetchGroupAttributeDescriptors(groupName)) {
// all this only really needs to consider properties
// of this class, not its subclasses, but since we
// are reusing code used for sequential selects, we
// use the subclass closure
int propertyNumber = getSubclassPropertyIndex(lazyAttributeDescriptor.getName());
int tableNumber = getSubclassPropertyTableNumber(propertyNumber);
tableNumbers.add(tableNumber);
int[] colNumbers = subclassPropertyColumnNumberClosure[propertyNumber];
for (int colNumber : colNumbers) {
if (colNumber != -1) {
columnNumbers.add(colNumber);
}
}
int[] formNumbers = subclassPropertyFormulaNumberClosure[propertyNumber];
for (int formNumber : formNumbers) {
if (formNumber != -1) {
formulaNumbers.add(formNumber);
}
}
}
if (columnNumbers.size() == 0 && formulaNumbers.size() == 0) {
// only one-to-one is lazy fetched
continue;
}
result.put(groupName, renderSelect(ArrayHelper.toIntArray(tableNumbers), ArrayHelper.toIntArray(columnNumbers), ArrayHelper.toIntArray(formulaNumbers)));
}
return result;
}
use of org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributesMetadata in project hibernate-orm by hibernate.
the class BytecodeEnhancementMetadataPojoImpl method from.
public static BytecodeEnhancementMetadata from(PersistentClass persistentClass) {
final Class mappedClass = persistentClass.getMappedClass();
final boolean enhancedForLazyLoading = PersistentAttributeInterceptable.class.isAssignableFrom(mappedClass);
final LazyAttributesMetadata lazyAttributesMetadata = enhancedForLazyLoading ? LazyAttributesMetadata.from(persistentClass) : LazyAttributesMetadata.nonEnhanced(persistentClass.getEntityName());
return new BytecodeEnhancementMetadataPojoImpl(persistentClass.getEntityName(), mappedClass, enhancedForLazyLoading, lazyAttributesMetadata);
}
Aggregations