use of org.hibernate.engine.spi.CompositeOwner in project hibernate-orm by hibernate.
the class PersistentAttributeTransformer method applyTo.
DynamicType.Builder<?> applyTo(DynamicType.Builder<?> builder, boolean accessor) {
boolean compositeOwner = false;
builder = builder.visit(new AsmVisitorWrapper.ForDeclaredMethods().method(not(nameStartsWith("$$_hibernate_")), this));
for (FieldDescription enhancedField : enhancedFields) {
builder = builder.defineMethod(EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + enhancedField.getName(), enhancedField.getType().asErasure(), Visibility.PUBLIC).intercept(accessor ? FieldAccessor.ofField(enhancedField.getName()).in(enhancedField.getDeclaringType().asErasure()) : fieldReader(enhancedField)).defineMethod(EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + enhancedField.getName(), TypeDescription.VOID, Visibility.PUBLIC).withParameters(enhancedField.getType().asErasure()).intercept(accessor ? FieldAccessor.ofField(enhancedField.getName()).in(enhancedField.getDeclaringType().asErasure()) : fieldWriter(enhancedField));
if (!compositeOwner && !accessor && EnhancerImpl.isAnnotationPresent(enhancedField, Embedded.class) && enhancementContext.isCompositeClass(enhancedField.getType().asErasure()) && enhancementContext.doDirtyCheckingInline(managedCtClass)) {
compositeOwner = true;
}
}
if (compositeOwner) {
builder = builder.implement(CompositeOwner.class);
if (enhancementContext.isCompositeClass(managedCtClass)) {
builder = builder.defineMethod(EnhancerConstants.TRACKER_CHANGER_NAME, void.class, Visibility.PUBLIC).withParameters(String.class).intercept(Advice.to(CodeTemplates.CompositeOwnerDirtyCheckingHandler.class).wrap(StubMethod.INSTANCE));
}
}
if (enhancementContext.doExtendedEnhancement(managedCtClass)) {
builder = applyExtended(builder);
}
return builder;
}
Aggregations