Skip to content

Commit fe7fc9b

Browse files
leonschenkbeikov
authored andcommitted
HHH-18675: Fix for testcase. If property is 'synthetic' then create no attribute for the jpa model.
(cherry picked from commit bc4804a)
1 parent 907fbe0 commit fe7fc9b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
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
@@ -496,7 +496,7 @@ public Generator createGenerator(RuntimeModelCreationContext context) {
496496
}
497497

498498
public Property copy() {
499-
final Property property = new Property();
499+
final Property property = this instanceof SyntheticProperty ? new SyntheticProperty() : new Property();
500500
property.setName( getName() );
501501
property.setValue( getValue() );
502502
property.setCascade( getCascade() );

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ public Map<String, IdentifiableDomainType<?>> getIdentifiableTypesByName() {
279279
attribute = factoryFunction.apply( entityType, genericProperty );
280280
if ( !property.isGeneric() ) {
281281
final PersistentAttribute<X, ?> concreteAttribute = factoryFunction.apply( entityType, property );
282-
//noinspection unchecked
283-
( (AttributeContainer<X>) entityType ).getInFlightAccess().addConcreteGenericAttribute( concreteAttribute );
282+
if ( concreteAttribute != null ) {
283+
@SuppressWarnings("unchecked") final AttributeContainer<X> attributeContainer = (AttributeContainer<X>) entityType;
284+
attributeContainer.getInFlightAccess().addConcreteGenericAttribute( concreteAttribute );
285+
}
284286
}
285287
}
286288
else {

0 commit comments

Comments
 (0)