From e38ae96acfcd4da7b2fd24628b78280413a1d6c1 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 11 Dec 2024 09:24:10 +0100 Subject: [PATCH] HHH-18868 Cleanup tests and mapper-supers identifier mapper check --- .../org/hibernate/metamodel/internal/MetadataContext.java | 8 +++++--- .../test/idclass/{ => mappedsuperclass}/BaseSummary.java | 2 +- .../MappedSuperclassIdClassAttributesTest.java | 6 ++---- .../orm/test/idclass/{ => mappedsuperclass}/PKey.java | 2 +- .../orm/test/idclass/{ => mappedsuperclass}/Summary.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename hibernate-core/src/test/java/org/hibernate/orm/test/idclass/{ => mappedsuperclass}/BaseSummary.java (95%) rename hibernate-core/src/test/java/org/hibernate/orm/test/idclass/{ => mappedsuperclass}/MappedSuperclassIdClassAttributesTest.java (93%) rename hibernate-core/src/test/java/org/hibernate/orm/test/idclass/{ => mappedsuperclass}/PKey.java (93%) rename hibernate-core/src/test/java/org/hibernate/orm/test/idclass/{ => mappedsuperclass}/Summary.java (77%) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java index e3a60f0a0e..5d78329462 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java @@ -357,7 +357,7 @@ public class MetadataContext { // #buildIdClassAttributes continue; } - if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) { + else if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) { // skip the version property, it was already handled previously. continue; } @@ -415,8 +415,10 @@ public class MetadataContext { private static boolean isIdentifierProperty(Property property, MappedSuperclass mappedSuperclass) { final Component identifierMapper = mappedSuperclass.getIdentifierMapper(); - return identifierMapper != null ? - ArrayHelper.contains( identifierMapper.getPropertyNames(), property.getName() ) : false; + return identifierMapper != null && ArrayHelper.contains( + identifierMapper.getPropertyNames(), + property.getName() + ); } private void addAttribute(EmbeddableDomainType embeddable, Property property, Component component) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/BaseSummary.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/BaseSummary.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/orm/test/idclass/BaseSummary.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/BaseSummary.java index 03f409ca01..822bd83011 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/BaseSummary.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/BaseSummary.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.orm.test.idclass; +package org.hibernate.orm.test.idclass.mappedsuperclass; import jakarta.persistence.Id; import jakarta.persistence.IdClass; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/MappedSuperclassIdClassAttributesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/MappedSuperclassIdClassAttributesTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/orm/test/idclass/MappedSuperclassIdClassAttributesTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/MappedSuperclassIdClassAttributesTest.java index d7d8738e22..9782f919a4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/MappedSuperclassIdClassAttributesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/MappedSuperclassIdClassAttributesTest.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.orm.test.idclass; +package org.hibernate.orm.test.idclass.mappedsuperclass; import jakarta.persistence.metamodel.SingularAttribute; import org.hibernate.testing.orm.junit.DomainModel; @@ -11,14 +11,12 @@ import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.Test; - import static org.assertj.core.api.Assertions.assertThat; @DomainModel(annotatedClasses = {Summary.class, BaseSummary.class}) @SessionFactory -@JiraKey( "HHH-18858" ) +@JiraKey("HHH-18858") public class MappedSuperclassIdClassAttributesTest { - @Test public void test(SessionFactoryScope scope) { scope.inSession( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/PKey.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/PKey.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/orm/test/idclass/PKey.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/PKey.java index 5b4a8ea3b5..6757d23edc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/PKey.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/PKey.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.orm.test.idclass; +package org.hibernate.orm.test.idclass.mappedsuperclass; import java.io.Serializable; import java.util.Objects; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/Summary.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/Summary.java similarity index 77% rename from hibernate-core/src/test/java/org/hibernate/orm/test/idclass/Summary.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/Summary.java index 391717ad38..108602a2ce 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/Summary.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/mappedsuperclass/Summary.java @@ -2,7 +2,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later * Copyright Red Hat Inc. and Hibernate Authors */ -package org.hibernate.orm.test.idclass; +package org.hibernate.orm.test.idclass.mappedsuperclass; import jakarta.persistence.Entity;