diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java index c743993a59..17bd8e277a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java @@ -285,10 +285,8 @@ public class EntityClass extends ConfiguredClass { } optimisticLockStyle = OptimisticLockStyle.valueOf( optimisticLockType.name() ); - final AnnotationInstance hibernateImmutableAnnotation = JandexHelper.getSingleAnnotation( - getClassInfo(), HibernateDotNames.IMMUTABLE - ); - isMutable = hibernateImmutableAnnotation == null + List< AnnotationInstance > hibernateImmutableAnnotations = getClassInfo().annotations().get( HibernateDotNames.IMMUTABLE ); + isMutable = ( hibernateImmutableAnnotations == null || hibernateImmutableAnnotations.isEmpty() ) && hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "mutable" ) != null && hibernateEntityAnnotation.value( "mutable" ).asBoolean(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/immutable/ImmutableTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/immutable/ImmutableTest.java index 7f99334c93..693f095ef6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/immutable/ImmutableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/immutable/ImmutableTest.java @@ -23,12 +23,14 @@ */ package org.hibernate.test.annotations.immutable; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.List; -import org.jboss.logging.Logger; -import org.junit.Test; - import org.hibernate.AnnotationException; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -37,11 +39,8 @@ import org.hibernate.cfg.Configuration; import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.jboss.logging.Logger; +import org.junit.Test; /** * Tests for Immutable annotation. @@ -53,7 +52,6 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase { private static final Logger log = Logger.getLogger( ImmutableTest.class ); @Test - @FailureExpectedWithNewMetamodel public void testImmutableEntity() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction();