HHH-14220 EnhancementException failure with MappedSuperclass with a un-mapped collection
This commit is contained in:
parent
a047e9a136
commit
cddb67f103
|
@ -230,38 +230,55 @@ public class EnhancerImpl implements Enhancer {
|
||||||
|
|
||||||
Implementation isDirty = StubMethod.INSTANCE, getDirtyNames = StubMethod.INSTANCE, clearDirtyNames = StubMethod.INSTANCE;
|
Implementation isDirty = StubMethod.INSTANCE, getDirtyNames = StubMethod.INSTANCE, clearDirtyNames = StubMethod.INSTANCE;
|
||||||
for ( AnnotatedFieldDescription collectionField : collectionFields ) {
|
for ( AnnotatedFieldDescription collectionField : collectionFields ) {
|
||||||
|
String collectionFieldName = collectionField.getName();
|
||||||
|
Class adviceIsDirty;
|
||||||
|
Class adviceGetDirtyNames;
|
||||||
|
Class adviceClearDirtyNames;
|
||||||
if ( collectionField.getType().asErasure().isAssignableTo( Map.class ) ) {
|
if ( collectionField.getType().asErasure().isAssignableTo( Map.class ) ) {
|
||||||
|
adviceIsDirty = CodeTemplates.MapAreCollectionFieldsDirty.class;
|
||||||
|
adviceGetDirtyNames = CodeTemplates.MapGetCollectionFieldDirtyNames.class;
|
||||||
|
adviceClearDirtyNames = CodeTemplates.MapGetCollectionClearDirtyNames.class;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
adviceIsDirty = CodeTemplates.CollectionAreCollectionFieldsDirty.class;
|
||||||
|
adviceGetDirtyNames = CodeTemplates.CollectionGetCollectionFieldDirtyNames.class;
|
||||||
|
adviceClearDirtyNames = CodeTemplates.CollectionGetCollectionClearDirtyNames.class;
|
||||||
|
}
|
||||||
|
if ( collectionField.isVisibleTo( managedCtClass ) ) {
|
||||||
|
FieldDescription fieldDescription = collectionField.getFieldDescription();
|
||||||
isDirty = Advice.withCustomMapping()
|
isDirty = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, fieldDescription )
|
||||||
.to( CodeTemplates.MapAreCollectionFieldsDirty.class, adviceLocator )
|
.to( adviceIsDirty, adviceLocator )
|
||||||
.wrap( isDirty );
|
.wrap( isDirty );
|
||||||
getDirtyNames = Advice.withCustomMapping()
|
getDirtyNames = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, fieldDescription )
|
||||||
.to( CodeTemplates.MapGetCollectionFieldDirtyNames.class, adviceLocator )
|
.to( adviceGetDirtyNames, adviceLocator )
|
||||||
.wrap( getDirtyNames );
|
.wrap( getDirtyNames );
|
||||||
clearDirtyNames = Advice.withCustomMapping()
|
clearDirtyNames = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, fieldDescription )
|
||||||
.to( CodeTemplates.MapGetCollectionClearDirtyNames.class, adviceLocator )
|
.to( adviceClearDirtyNames, adviceLocator )
|
||||||
.wrap( clearDirtyNames );
|
.wrap( clearDirtyNames );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
CodeTemplates.GetterMapping getterMapping = new CodeTemplates.GetterMapping(
|
||||||
|
collectionField.getFieldDescription() );
|
||||||
isDirty = Advice.withCustomMapping()
|
isDirty = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, getterMapping )
|
||||||
.to( CodeTemplates.CollectionAreCollectionFieldsDirty.class, adviceLocator )
|
.to( adviceIsDirty, adviceLocator )
|
||||||
.wrap( isDirty );
|
.wrap( isDirty );
|
||||||
getDirtyNames = Advice.withCustomMapping()
|
getDirtyNames = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, getterMapping )
|
||||||
.to( CodeTemplates.CollectionGetCollectionFieldDirtyNames.class, adviceLocator )
|
.to( adviceGetDirtyNames, adviceLocator )
|
||||||
.wrap( getDirtyNames );
|
.wrap( getDirtyNames );
|
||||||
clearDirtyNames = Advice.withCustomMapping()
|
clearDirtyNames = Advice.withCustomMapping()
|
||||||
.bind( CodeTemplates.FieldName.class, collectionField.getName() )
|
.bind( CodeTemplates.FieldName.class, collectionFieldName )
|
||||||
.bind( CodeTemplates.FieldValue.class, collectionField.getFieldDescription() )
|
.bind( CodeTemplates.FieldValue.class, getterMapping )
|
||||||
.to( CodeTemplates.CollectionGetCollectionClearDirtyNames.class, adviceLocator )
|
.to( adviceClearDirtyNames, adviceLocator )
|
||||||
.wrap( clearDirtyNames );
|
.wrap( clearDirtyNames );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue