HHH-8221 - mocking orm.xml is not processed well

This commit is contained in:
Strong Liu 2013-05-03 18:28:17 +08:00
parent 262c109e64
commit 72291316fc
6 changed files with 65 additions and 66 deletions

View File

@ -3378,7 +3378,14 @@ public class Binder {
tableIdentifier = referencedEntityBinding.getPrimaryTable().getLogicalName(); 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 ); return schema.locateTable( tableIdentifier );
} }

View File

@ -43,11 +43,12 @@ import org.hibernate.metamodel.internal.source.annotations.xml.mocker.MockHelper
class ExclusiveAnnotationFilter extends AbstractAnnotationFilter { class ExclusiveAnnotationFilter extends AbstractAnnotationFilter {
public static ExclusiveAnnotationFilter INSTANCE = new ExclusiveAnnotationFilter(); public static ExclusiveAnnotationFilter INSTANCE = new ExclusiveAnnotationFilter();
private DotName[] targetNames; private final DotName[] targetNames;
private List<ExclusiveGroup> exclusiveGroupList; private final List<ExclusiveGroup> exclusiveGroupList;
private ExclusiveAnnotationFilter() { private ExclusiveAnnotationFilter() {
this.exclusiveGroupList = getExclusiveGroupList(); this.exclusiveGroupList = new ArrayList<ExclusiveGroup>();
fillExclusiveGroupList();
Set<DotName> names = new HashSet<DotName>(); Set<DotName> names = new HashSet<DotName>();
for ( ExclusiveGroup group : exclusiveGroupList ) { for ( ExclusiveGroup group : exclusiveGroupList ) {
names.addAll( group.getNames() ); names.addAll( group.getNames() );
@ -55,9 +56,7 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter {
targetNames = names.toArray( new DotName[names.size()] ); targetNames = names.toArray( new DotName[names.size()] );
} }
private List<ExclusiveGroup> getExclusiveGroupList() { private void fillExclusiveGroupList() {
if ( exclusiveGroupList == null ) {
exclusiveGroupList = new ArrayList<ExclusiveGroup>();
ExclusiveGroup group = new ExclusiveGroup(); ExclusiveGroup group = new ExclusiveGroup();
group.add( ENTITY ); group.add( ENTITY );
group.add( MAPPED_SUPERCLASS ); group.add( MAPPED_SUPERCLASS );
@ -114,8 +113,6 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter {
exclusiveGroupList.add( group ); exclusiveGroupList.add( group );
} }
return exclusiveGroupList;
}
@Override @Override
protected void overrideIndexedAnnotationMap(DotName annName, AnnotationInstance annotationInstance, Map<DotName, List<AnnotationInstance>> map) { protected void overrideIndexedAnnotationMap(DotName annName, AnnotationInstance annotationInstance, Map<DotName, List<AnnotationInstance>> map) {

View File

@ -39,11 +39,8 @@ class NameAnnotationFilter extends AbstractAnnotationFilter {
indexedAnnotationInstanceList.clear(); indexedAnnotationInstanceList.clear();
} }
public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter(); public static NameAnnotationFilter INSTANCE = new NameAnnotationFilter();
private static final DotName[] TARGET_ANNOTATIONS = new DotName[] {
@Override
protected DotName[] targetAnnotation() {
return new DotName[] {
CACHEABLE, CACHEABLE,
TABLE, TABLE,
EXCLUDE_DEFAULT_LISTENERS, EXCLUDE_DEFAULT_LISTENERS,
@ -54,5 +51,8 @@ class NameAnnotationFilter extends AbstractAnnotationFilter {
DISCRIMINATOR_COLUMN, DISCRIMINATOR_COLUMN,
ENTITY_LISTENERS ENTITY_LISTENERS
}; };
@Override
protected DotName[] targetAnnotation() {
return TARGET_ANNOTATIONS;
} }
} }

View File

@ -50,10 +50,7 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter {
} }
public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter(); public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter();
private static final DotName[] TARGET_ANNOTATIONS = new DotName[] {
@Override
protected DotName[] targetAnnotation() {
return new DotName[] {
JPADotNames.LOB, JPADotNames.LOB,
JPADotNames.ID, JPADotNames.ID,
JPADotNames.BASIC, JPADotNames.BASIC,
@ -91,5 +88,8 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter {
JPADotNames.MAP_KEY_COLUMN, JPADotNames.MAP_KEY_COLUMN,
JPADotNames.MAP_KEY_ENUMERATED JPADotNames.MAP_KEY_ENUMERATED
}; };
@Override
protected DotName[] targetAnnotation() {
return TARGET_ANNOTATIONS;
} }
} }

View File

@ -34,12 +34,10 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jpa.AvailableSettings; import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@FailureExpectedWithNewMetamodel
public class XmlTest extends BaseEntityManagerFunctionalTestCase { public class XmlTest extends BaseEntityManagerFunctionalTestCase {
@Test @Test
public void testXmlMappingCorrectness() throws Exception { public void testXmlMappingCorrectness() throws Exception {

View File

@ -29,16 +29,13 @@ import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.jpa.test.xml.*;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@RequiresDialectFeature( DialectChecks.SupportsSequences.class ) @RequiresDialectFeature( DialectChecks.SupportsSequences.class )
@FailureExpectedWithNewMetamodel
public class XmlTest extends BaseEntityManagerFunctionalTestCase { public class XmlTest extends BaseEntityManagerFunctionalTestCase {
@Test @Test
public void testXmlMappingCorrectness() throws Exception { public void testXmlMappingCorrectness() throws Exception {