diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java index d9651cdc4e..9d1e77de50 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java @@ -3378,7 +3378,14 @@ public class Binder { tableIdentifier = referencedEntityBinding.getPrimaryTable().getLogicalName(); } - Schema schema = metadata.getDatabase().getSchema( logicalCatalogName, logicalSchemaName ); + + Identifier catalogName = StringHelper.isNotEmpty( logicalCatalogName ) ? + Identifier.toIdentifier( logicalCatalogName ) + : referencedEntityBinding.getPrimaryTable().getSchema().getName().getCatalog(); + Identifier schemaName = StringHelper.isNotEmpty( logicalCatalogName ) ? + Identifier.toIdentifier( logicalSchemaName ) + : referencedEntityBinding.getPrimaryTable().getSchema().getName().getSchema(); + Schema schema = metadata.getDatabase().getSchema( catalogName, schemaName ); return schema.locateTable( tableIdentifier ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/ExclusiveAnnotationFilter.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/ExclusiveAnnotationFilter.java index f651fdcd08..bc0510b717 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/ExclusiveAnnotationFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/ExclusiveAnnotationFilter.java @@ -43,11 +43,12 @@ import org.hibernate.metamodel.internal.source.annotations.xml.mocker.MockHelper class ExclusiveAnnotationFilter extends AbstractAnnotationFilter { public static ExclusiveAnnotationFilter INSTANCE = new ExclusiveAnnotationFilter(); - private DotName[] targetNames; - private List exclusiveGroupList; + private final DotName[] targetNames; + private final List exclusiveGroupList; private ExclusiveAnnotationFilter() { - this.exclusiveGroupList = getExclusiveGroupList(); + this.exclusiveGroupList = new ArrayList(); + fillExclusiveGroupList(); Set names = new HashSet(); for ( ExclusiveGroup group : exclusiveGroupList ) { names.addAll( group.getNames() ); @@ -55,9 +56,7 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter { targetNames = names.toArray( new DotName[names.size()] ); } - private List getExclusiveGroupList() { - if ( exclusiveGroupList == null ) { - exclusiveGroupList = new ArrayList(); + private void fillExclusiveGroupList() { ExclusiveGroup group = new ExclusiveGroup(); group.add( ENTITY ); group.add( MAPPED_SUPERCLASS ); @@ -113,8 +112,6 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter { group.scope = Scope.ATTRIBUTE; exclusiveGroupList.add( group ); - } - return exclusiveGroupList; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameAnnotationFilter.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameAnnotationFilter.java index c78befff78..fad2c811be 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameAnnotationFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameAnnotationFilter.java @@ -39,20 +39,20 @@ class NameAnnotationFilter extends AbstractAnnotationFilter { indexedAnnotationInstanceList.clear(); } - public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter(); - + public static NameAnnotationFilter INSTANCE = new NameAnnotationFilter(); + private static final DotName[] TARGET_ANNOTATIONS = new DotName[] { + CACHEABLE, + TABLE, + EXCLUDE_DEFAULT_LISTENERS, + EXCLUDE_SUPERCLASS_LISTENERS, + ID_CLASS, + INHERITANCE, + DISCRIMINATOR_VALUE, + DISCRIMINATOR_COLUMN, + ENTITY_LISTENERS + }; @Override protected DotName[] targetAnnotation() { - return new DotName[] { - CACHEABLE, - TABLE, - EXCLUDE_DEFAULT_LISTENERS, - EXCLUDE_SUPERCLASS_LISTENERS, - ID_CLASS, - INHERITANCE, - DISCRIMINATOR_VALUE, - DISCRIMINATOR_COLUMN, - ENTITY_LISTENERS - }; + return TARGET_ANNOTATIONS; } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameTargetAnnotationFilter.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameTargetAnnotationFilter.java index da0542bab1..0124f96810 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameTargetAnnotationFilter.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/filter/NameTargetAnnotationFilter.java @@ -50,46 +50,46 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter { } public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter(); - + private static final DotName[] TARGET_ANNOTATIONS = new DotName[] { + JPADotNames.LOB, + JPADotNames.ID, + JPADotNames.BASIC, + JPADotNames.GENERATED_VALUE, + JPADotNames.VERSION, + JPADotNames.TRANSIENT, + JPADotNames.ACCESS, + JPADotNames.POST_LOAD, + JPADotNames.POST_PERSIST, + JPADotNames.POST_REMOVE, + JPADotNames.POST_UPDATE, + JPADotNames.PRE_PERSIST, + JPADotNames.PRE_REMOVE, + JPADotNames.PRE_UPDATE, + JPADotNames.EMBEDDED_ID, + JPADotNames.EMBEDDED, + JPADotNames.MANY_TO_ONE, + JPADotNames.MANY_TO_MANY, + JPADotNames.ONE_TO_ONE, + JPADotNames.ONE_TO_MANY, + JPADotNames.ELEMENT_COLLECTION, + JPADotNames.COLLECTION_TABLE, + JPADotNames.COLUMN, + JPADotNames.ENUMERATED, + JPADotNames.JOIN_TABLE, + JPADotNames.TEMPORAL, + JPADotNames.ORDER_BY, + JPADotNames.ORDER_COLUMN, + JPADotNames.JOIN_COLUMN, + JPADotNames.JOIN_COLUMNS, + JPADotNames.MAPS_ID, + JPADotNames.MAP_KEY_TEMPORAL, + JPADotNames.MAP_KEY, + JPADotNames.MAP_KEY_CLASS, + JPADotNames.MAP_KEY_COLUMN, + JPADotNames.MAP_KEY_ENUMERATED + }; @Override protected DotName[] targetAnnotation() { - return new DotName[] { - JPADotNames.LOB, - JPADotNames.ID, - JPADotNames.BASIC, - JPADotNames.GENERATED_VALUE, - JPADotNames.VERSION, - JPADotNames.TRANSIENT, - JPADotNames.ACCESS, - JPADotNames.POST_LOAD, - JPADotNames.POST_PERSIST, - JPADotNames.POST_REMOVE, - JPADotNames.POST_UPDATE, - JPADotNames.PRE_PERSIST, - JPADotNames.PRE_REMOVE, - JPADotNames.PRE_UPDATE, - JPADotNames.EMBEDDED_ID, - JPADotNames.EMBEDDED, - JPADotNames.MANY_TO_ONE, - JPADotNames.MANY_TO_MANY, - JPADotNames.ONE_TO_ONE, - JPADotNames.ONE_TO_MANY, - JPADotNames.ELEMENT_COLLECTION, - JPADotNames.COLLECTION_TABLE, - JPADotNames.COLUMN, - JPADotNames.ENUMERATED, - JPADotNames.JOIN_TABLE, - JPADotNames.TEMPORAL, - JPADotNames.ORDER_BY, - JPADotNames.ORDER_COLUMN, - JPADotNames.JOIN_COLUMN, - JPADotNames.JOIN_COLUMNS, - JPADotNames.MAPS_ID, - JPADotNames.MAP_KEY_TEMPORAL, - JPADotNames.MAP_KEY, - JPADotNames.MAP_KEY_CLASS, - JPADotNames.MAP_KEY_COLUMN, - JPADotNames.MAP_KEY_ENUMERATED - }; + return TARGET_ANNOTATIONS; } } diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/XmlTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/XmlTest.java index 22c8a3b896..c4c1baf746 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/XmlTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/XmlTest.java @@ -34,12 +34,10 @@ import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jpa.AvailableSettings; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; /** * @author Emmanuel Bernard */ -@FailureExpectedWithNewMetamodel public class XmlTest extends BaseEntityManagerFunctionalTestCase { @Test public void testXmlMappingCorrectness() throws Exception { diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/sequences/XmlTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/sequences/XmlTest.java index 4f088354b1..f17bb0f246 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/sequences/XmlTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/xml/sequences/XmlTest.java @@ -29,16 +29,13 @@ import org.junit.Test; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; -import org.hibernate.jpa.test.xml.*; import org.hibernate.testing.DialectChecks; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.RequiresDialectFeature; /** * @author Emmanuel Bernard */ @RequiresDialectFeature( DialectChecks.SupportsSequences.class ) -@FailureExpectedWithNewMetamodel public class XmlTest extends BaseEntityManagerFunctionalTestCase { @Test public void testXmlMappingCorrectness() throws Exception {