HHH-18675: Fix for testcase. If property is 'synthetic' then create no attribute for the jpa model.

This commit is contained in:
Leon Schenk 2024-09-30 21:29:00 +02:00 committed by Christian Beikov
parent fcba4ed25d
commit bc4804ab09
2 changed files with 6 additions and 5 deletions

View File

@ -477,7 +477,7 @@ public class Property implements Serializable, MetaAttributable {
}
public Property copy() {
final Property property = new Property();
final Property property = this instanceof SyntheticProperty ? new SyntheticProperty() : new Property();
property.setName( getName() );
property.setValue( getValue() );
property.setCascade( getCascade() );

View File

@ -55,9 +55,9 @@ import java.util.Set;
import java.util.function.BiFunction;
import static java.util.Collections.unmodifiableMap;
import static java.util.Objects.nonNull;
import static org.hibernate.metamodel.internal.InjectionHelper.injectField;
/**
* Defines a context for storing information during the building of the {@link MappingMetamodelImpl}.
* <p>
@ -274,11 +274,12 @@ public class MetadataContext {
attribute = factoryFunction.apply( entityType, genericProperty );
if ( !property.isGeneric() ) {
final PersistentAttribute<X, ?> concreteAttribute = factoryFunction.apply( entityType, property );
@SuppressWarnings("unchecked")
final AttributeContainer<X> attributeContainer = (AttributeContainer<X>) entityType;
if (nonNull(concreteAttribute)) {
@SuppressWarnings("unchecked") final AttributeContainer<X> attributeContainer = (AttributeContainer<X>) entityType;
attributeContainer.getInFlightAccess().addConcreteGenericAttribute(concreteAttribute);
}
}
}
else {
attribute = factoryFunction.apply( entityType, property );
}