Skip to content

Commit bc4804a

Browse files
leonschenkbeikov
authored andcommitted
HHH-18675: Fix for testcase. If property is 'synthetic' then create no attribute for the jpa model.
1 parent fcba4ed commit bc4804a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

hibernate-core/src/main/java/org/hibernate/mapping/Property.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public Generator createGenerator(RuntimeModelCreationContext context) {
477477
}
478478

479479
public Property copy() {
480-
final Property property = new Property();
480+
final Property property = this instanceof SyntheticProperty ? new SyntheticProperty() : new Property();
481481
property.setName( getName() );
482482
property.setValue( getValue() );
483483
property.setCascade( getCascade() );

hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
import java.util.function.BiFunction;
5656

5757
import static java.util.Collections.unmodifiableMap;
58+
import static java.util.Objects.nonNull;
5859
import static org.hibernate.metamodel.internal.InjectionHelper.injectField;
5960

60-
6161
/**
6262
* Defines a context for storing information during the building of the {@link MappingMetamodelImpl}.
6363
* <p>
@@ -274,9 +274,10 @@ public Map<String, IdentifiableDomainType<?>> getIdentifiableTypesByName() {
274274
attribute = factoryFunction.apply( entityType, genericProperty );
275275
if ( !property.isGeneric() ) {
276276
final PersistentAttribute<X, ?> concreteAttribute = factoryFunction.apply( entityType, property );
277-
@SuppressWarnings("unchecked")
278-
final AttributeContainer<X> attributeContainer = (AttributeContainer<X>) entityType;
279-
attributeContainer.getInFlightAccess().addConcreteGenericAttribute( concreteAttribute );
277+
if (nonNull(concreteAttribute)) {
278+
@SuppressWarnings("unchecked") final AttributeContainer<X> attributeContainer = (AttributeContainer<X>) entityType;
279+
attributeContainer.getInFlightAccess().addConcreteGenericAttribute(concreteAttribute);
280+
}
280281
}
281282
}
282283
else {

0 commit comments

Comments
 (0)