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();
}
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 );
}

View File

@ -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<ExclusiveGroup> exclusiveGroupList;
private final DotName[] targetNames;
private final List<ExclusiveGroup> exclusiveGroupList;
private ExclusiveAnnotationFilter() {
this.exclusiveGroupList = getExclusiveGroupList();
this.exclusiveGroupList = new ArrayList<ExclusiveGroup>();
fillExclusiveGroupList();
Set<DotName> names = new HashSet<DotName>();
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<ExclusiveGroup> getExclusiveGroupList() {
if ( exclusiveGroupList == null ) {
exclusiveGroupList = new ArrayList<ExclusiveGroup>();
private void fillExclusiveGroupList() {
ExclusiveGroup group = new ExclusiveGroup();
group.add( ENTITY );
group.add( MAPPED_SUPERCLASS );
@ -114,8 +113,6 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter {
exclusiveGroupList.add( group );
}
return exclusiveGroupList;
}
@Override
protected void overrideIndexedAnnotationMap(DotName annName, AnnotationInstance annotationInstance, Map<DotName, List<AnnotationInstance>> map) {

View File

@ -39,11 +39,8 @@ class NameAnnotationFilter extends AbstractAnnotationFilter {
indexedAnnotationInstanceList.clear();
}
public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter();
@Override
protected DotName[] targetAnnotation() {
return new DotName[] {
public static NameAnnotationFilter INSTANCE = new NameAnnotationFilter();
private static final DotName[] TARGET_ANNOTATIONS = new DotName[] {
CACHEABLE,
TABLE,
EXCLUDE_DEFAULT_LISTENERS,
@ -54,5 +51,8 @@ class NameAnnotationFilter extends AbstractAnnotationFilter {
DISCRIMINATOR_COLUMN,
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();
@Override
protected DotName[] targetAnnotation() {
return new DotName[] {
private static final DotName[] TARGET_ANNOTATIONS = new DotName[] {
JPADotNames.LOB,
JPADotNames.ID,
JPADotNames.BASIC,
@ -91,5 +88,8 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter {
JPADotNames.MAP_KEY_COLUMN,
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.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 {

View File

@ -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 {