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() { public Property copy() {
final Property property = new Property(); final Property property = this instanceof SyntheticProperty ? new SyntheticProperty() : new Property();
property.setName( getName() ); property.setName( getName() );
property.setValue( getValue() ); property.setValue( getValue() );
property.setCascade( getCascade() ); property.setCascade( getCascade() );

View File

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