HHH-7351 Fixed wrong usage of index.getAnnotations and updates tests
This commit is contained in:
parent
f4cb1846e4
commit
74300e6120
|
@ -94,7 +94,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
index = parseAndUpdateIndex( mappings, index );
|
index = parseAndUpdateIndex( mappings, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ) != null ) {
|
if ( !index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ).isEmpty() ) {
|
||||||
// todo : this needs to move to AnnotationBindingContext
|
// todo : this needs to move to AnnotationBindingContext
|
||||||
// what happens right now is that specifying this in an orm.xml causes it to effect all orm.xmls
|
// what happens right now is that specifying this in an orm.xml causes it to effect all orm.xmls
|
||||||
metadata.setGloballyQuotedIdentifiers( true );
|
metadata.setGloballyQuotedIdentifiers( true );
|
||||||
|
|
|
@ -129,7 +129,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
SingularAttributeBinding.class.cast(
|
SingularAttributeBinding.class.cast(
|
||||||
simpleEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding()
|
simpleEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding()
|
||||||
),
|
),
|
||||||
"`simpleEntity`"
|
"simpleEntity"
|
||||||
);
|
);
|
||||||
|
|
||||||
checkManyToOneAttributeBinding(
|
checkManyToOneAttributeBinding(
|
||||||
|
@ -137,7 +137,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
entityWithManyToOneBinding,
|
entityWithManyToOneBinding,
|
||||||
entityWithManyToOneBinding.locateAttributeBinding( "simpleEntityFromPropertyRef" ),
|
entityWithManyToOneBinding.locateAttributeBinding( "simpleEntityFromPropertyRef" ),
|
||||||
SingularAttributeBinding.class.cast( simpleEntityBinding.locateAttributeBinding( "name" ) ),
|
SingularAttributeBinding.class.cast( simpleEntityBinding.locateAttributeBinding( "name" ) ),
|
||||||
"`simplename`"
|
"simplename"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertSame( bagBinding, entityBinding.locateAttributeBinding( "theBag" ) );
|
assertSame( bagBinding, entityBinding.locateAttributeBinding( "theBag" ) );
|
||||||
TableSpecification bagCollectionTable = bagBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
TableSpecification bagCollectionTable = bagBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
||||||
assertNotNull( bagCollectionTable );
|
assertNotNull( bagCollectionTable );
|
||||||
assertEquals( Identifier.toIdentifier( "`EntityWithBasicCollections_theBag`" ), bagCollectionTable.getLogicalName() );
|
assertEquals( Identifier.toIdentifier( "EntityWithBasicCollections_theBag" ), bagCollectionTable.getLogicalName() );
|
||||||
PluralAttributeKeyBinding bagKeyBinding = bagBinding.getPluralAttributeKeyBinding();
|
PluralAttributeKeyBinding bagKeyBinding = bagBinding.getPluralAttributeKeyBinding();
|
||||||
assertSame( bagBinding, bagKeyBinding.getPluralAttributeBinding() );
|
assertSame( bagBinding, bagKeyBinding.getPluralAttributeBinding() );
|
||||||
HibernateTypeDescriptor bagHibernateTypeDescriptor = bagBinding.getHibernateTypeDescriptor();
|
HibernateTypeDescriptor bagHibernateTypeDescriptor = bagBinding.getHibernateTypeDescriptor();
|
||||||
|
@ -119,8 +119,8 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertNotNull( fkBagSourceColumnIterator );
|
assertNotNull( fkBagSourceColumnIterator );
|
||||||
assertTrue( fkBagColumnIterator.hasNext() );
|
assertTrue( fkBagColumnIterator.hasNext() );
|
||||||
assertTrue( fkBagSourceColumnIterator.hasNext() );
|
assertTrue( fkBagSourceColumnIterator.hasNext() );
|
||||||
assertEquals( Identifier.toIdentifier( "`owner_id`" ), fkBagColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "owner_id" ), fkBagColumnIterator.next().getColumnName() );
|
||||||
assertEquals( Identifier.toIdentifier( "`owner_id`" ), fkBagSourceColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "owner_id" ), fkBagSourceColumnIterator.next().getColumnName() );
|
||||||
assertFalse( fkBagColumnIterator.hasNext() );
|
assertFalse( fkBagColumnIterator.hasNext() );
|
||||||
assertFalse( fkBagSourceColumnIterator.hasNext() );
|
assertFalse( fkBagSourceColumnIterator.hasNext() );
|
||||||
assertSame( entityBinding.getPrimaryTable(), fkBag.getTargetTable() );
|
assertSame( entityBinding.getPrimaryTable(), fkBag.getTargetTable() );
|
||||||
|
@ -147,7 +147,7 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertSame( setBinding, entityBinding.locateAttributeBinding( "theSet" ) );
|
assertSame( setBinding, entityBinding.locateAttributeBinding( "theSet" ) );
|
||||||
TableSpecification setCollectionTable = setBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
TableSpecification setCollectionTable = setBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
||||||
assertNotNull( setCollectionTable );
|
assertNotNull( setCollectionTable );
|
||||||
assertEquals( Identifier.toIdentifier( "`EntityWithBasicCollections_theSet`" ), setCollectionTable.getLogicalName() );
|
assertEquals( Identifier.toIdentifier( "EntityWithBasicCollections_theSet" ), setCollectionTable.getLogicalName() );
|
||||||
PluralAttributeKeyBinding setKeyBinding = setBinding.getPluralAttributeKeyBinding();
|
PluralAttributeKeyBinding setKeyBinding = setBinding.getPluralAttributeKeyBinding();
|
||||||
assertSame( setBinding, setKeyBinding.getPluralAttributeBinding() );
|
assertSame( setBinding, setKeyBinding.getPluralAttributeBinding() );
|
||||||
HibernateTypeDescriptor setHibernateTypeDescriptor = setBinding.getHibernateTypeDescriptor();
|
HibernateTypeDescriptor setHibernateTypeDescriptor = setBinding.getHibernateTypeDescriptor();
|
||||||
|
@ -170,8 +170,8 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertNotNull( fkSetSourceColumnIterator );
|
assertNotNull( fkSetSourceColumnIterator );
|
||||||
assertTrue( fkSetColumnIterator.hasNext() );
|
assertTrue( fkSetColumnIterator.hasNext() );
|
||||||
assertTrue( fkSetSourceColumnIterator.hasNext() );
|
assertTrue( fkSetSourceColumnIterator.hasNext() );
|
||||||
assertEquals( Identifier.toIdentifier( "`pid`" ), fkSetColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "pid" ), fkSetColumnIterator.next().getColumnName() );
|
||||||
assertEquals( Identifier.toIdentifier( "`pid`" ), fkSetSourceColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "pid" ), fkSetSourceColumnIterator.next().getColumnName() );
|
||||||
assertFalse( fkSetColumnIterator.hasNext() );
|
assertFalse( fkSetColumnIterator.hasNext() );
|
||||||
assertFalse( fkSetSourceColumnIterator.hasNext() );
|
assertFalse( fkSetSourceColumnIterator.hasNext() );
|
||||||
assertSame( entityBinding.getPrimaryTable(), fkSet.getTargetTable() );
|
assertSame( entityBinding.getPrimaryTable(), fkSet.getTargetTable() );
|
||||||
|
@ -192,7 +192,7 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
setPrimaryKeyIterator.next().getJdbcDataType()
|
setPrimaryKeyIterator.next().getJdbcDataType()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
setCollectionTable.locateColumn( "`set_stuff`" ).getJdbcDataType(),
|
setCollectionTable.locateColumn( "set_stuff" ).getJdbcDataType(),
|
||||||
setPrimaryKeyIterator.next().getJdbcDataType()
|
setPrimaryKeyIterator.next().getJdbcDataType()
|
||||||
);
|
);
|
||||||
assertFalse( setPrimaryKeyIterator.hasNext() );
|
assertFalse( setPrimaryKeyIterator.hasNext() );
|
||||||
|
@ -208,7 +208,7 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertSame( propertyRefSetBinding, entityBinding.locateAttributeBinding( "thePropertyRefSet" ) );
|
assertSame( propertyRefSetBinding, entityBinding.locateAttributeBinding( "thePropertyRefSet" ) );
|
||||||
TableSpecification propertyRefSetCollectionTable = propertyRefSetBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
TableSpecification propertyRefSetCollectionTable = propertyRefSetBinding.getPluralAttributeKeyBinding().getCollectionTable();
|
||||||
assertNotNull( propertyRefSetCollectionTable );
|
assertNotNull( propertyRefSetCollectionTable );
|
||||||
assertEquals( Identifier.toIdentifier( "`EntityWithBasicCollections_thePropertyRefSet`" ), propertyRefSetCollectionTable.getLogicalName() );
|
assertEquals( Identifier.toIdentifier( "EntityWithBasicCollections_thePropertyRefSet" ), propertyRefSetCollectionTable.getLogicalName() );
|
||||||
PluralAttributeKeyBinding propertyRefSetKeyBinding = propertyRefSetBinding.getPluralAttributeKeyBinding();
|
PluralAttributeKeyBinding propertyRefSetKeyBinding = propertyRefSetBinding.getPluralAttributeKeyBinding();
|
||||||
assertSame( propertyRefSetBinding, propertyRefSetKeyBinding.getPluralAttributeBinding() );
|
assertSame( propertyRefSetBinding, propertyRefSetKeyBinding.getPluralAttributeBinding() );
|
||||||
HibernateTypeDescriptor propertyRefSetHibernateTypeDescriptor = propertyRefSetBinding.getHibernateTypeDescriptor();
|
HibernateTypeDescriptor propertyRefSetHibernateTypeDescriptor = propertyRefSetBinding.getHibernateTypeDescriptor();
|
||||||
|
@ -234,12 +234,12 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertNotNull( fkPropertyRefSetSourceColumnIterator );
|
assertNotNull( fkPropertyRefSetSourceColumnIterator );
|
||||||
assertTrue( fkPropertyRefSetColumnIterator.hasNext() );
|
assertTrue( fkPropertyRefSetColumnIterator.hasNext() );
|
||||||
assertTrue( fkPropertyRefSetSourceColumnIterator.hasNext() );
|
assertTrue( fkPropertyRefSetSourceColumnIterator.hasNext() );
|
||||||
assertEquals( Identifier.toIdentifier( "`pid`" ), fkPropertyRefSetColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "pid" ), fkPropertyRefSetColumnIterator.next().getColumnName() );
|
||||||
assertEquals( Identifier.toIdentifier( "`pid`" ), fkPropertyRefSetSourceColumnIterator.next().getColumnName() );
|
assertEquals( Identifier.toIdentifier( "pid" ), fkPropertyRefSetSourceColumnIterator.next().getColumnName() );
|
||||||
assertFalse( fkPropertyRefSetColumnIterator.hasNext() );
|
assertFalse( fkPropertyRefSetColumnIterator.hasNext() );
|
||||||
assertFalse( fkPropertyRefSetSourceColumnIterator.hasNext() );
|
assertFalse( fkPropertyRefSetSourceColumnIterator.hasNext() );
|
||||||
assertSame( entityBinding.getPrimaryTable(), fkPropertyRefSet.getTargetTable() );
|
assertSame( entityBinding.getPrimaryTable(), fkPropertyRefSet.getTargetTable() );
|
||||||
assertSame( entityBinding.getPrimaryTable().locateColumn( "`name`" ), fkPropertyRefSet.getTargetColumns().iterator().next() );
|
assertSame( entityBinding.getPrimaryTable().locateColumn( "name" ), fkPropertyRefSet.getTargetColumns().iterator().next() );
|
||||||
assertSame( ForeignKey.ReferentialAction.NO_ACTION, fkPropertyRefSet.getDeleteRule() );
|
assertSame( ForeignKey.ReferentialAction.NO_ACTION, fkPropertyRefSet.getDeleteRule() );
|
||||||
assertSame( ForeignKey.ReferentialAction.NO_ACTION, fkPropertyRefSet.getUpdateRule() );
|
assertSame( ForeignKey.ReferentialAction.NO_ACTION, fkPropertyRefSet.getUpdateRule() );
|
||||||
// FK is null because no default FK name is generated until HHH-7092 is fixed
|
// FK is null because no default FK name is generated until HHH-7092 is fixed
|
||||||
|
@ -252,11 +252,11 @@ public class BasicCollectionBindingTests extends BaseUnitTestCase {
|
||||||
assertEquals( 2, propertyRefSetCollectionTable.getPrimaryKey().getColumnSpan() );
|
assertEquals( 2, propertyRefSetCollectionTable.getPrimaryKey().getColumnSpan() );
|
||||||
Iterator<Column> propertyRefSetPrimaryKeyIterator = propertyRefSetCollectionTable.getPrimaryKey().getColumns().iterator();
|
Iterator<Column> propertyRefSetPrimaryKeyIterator = propertyRefSetCollectionTable.getPrimaryKey().getColumns().iterator();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
entityBinding.getPrimaryTable().locateColumn( "`name`" ).getJdbcDataType(),
|
entityBinding.getPrimaryTable().locateColumn( "name" ).getJdbcDataType(),
|
||||||
propertyRefSetPrimaryKeyIterator.next().getJdbcDataType()
|
propertyRefSetPrimaryKeyIterator.next().getJdbcDataType()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
propertyRefSetCollectionTable.locateColumn( "`property_ref_set_stuff`" ).getJdbcDataType(),
|
propertyRefSetCollectionTable.locateColumn( "property_ref_set_stuff" ).getJdbcDataType(),
|
||||||
propertyRefSetPrimaryKeyIterator.next().getJdbcDataType()
|
propertyRefSetPrimaryKeyIterator.next().getJdbcDataType()
|
||||||
);
|
);
|
||||||
assertFalse( propertyRefSetPrimaryKeyIterator.hasNext() );
|
assertFalse( propertyRefSetPrimaryKeyIterator.hasNext() );
|
||||||
|
|
|
@ -90,10 +90,10 @@ public class UnidirectionalOneToManyBindingTests extends BaseUnitTestCase {
|
||||||
final EntityBinding simpleEntityBinding = metadata.getEntityBinding( SimpleEntity.class.getName() );
|
final EntityBinding simpleEntityBinding = metadata.getEntityBinding( SimpleEntity.class.getName() );
|
||||||
assertNotNull( entityBinding );
|
assertNotNull( entityBinding );
|
||||||
|
|
||||||
assertEquals( Identifier.toIdentifier( "`SimpleEntity`" ), simpleEntityBinding.getPrimaryTable().getLogicalName() );
|
assertEquals( Identifier.toIdentifier( "SimpleEntity" ), simpleEntityBinding.getPrimaryTable().getLogicalName() );
|
||||||
assertEquals( 1, simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumnSpan() );
|
assertEquals( 1, simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumnSpan() );
|
||||||
Column simpleEntityIdColumn = simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumns().get( 0 );
|
Column simpleEntityIdColumn = simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumns().get( 0 );
|
||||||
assertEquals( Identifier.toIdentifier("`id`") , simpleEntityIdColumn.getColumnName() );
|
assertEquals( Identifier.toIdentifier("id") , simpleEntityIdColumn.getColumnName() );
|
||||||
|
|
||||||
checkResult(
|
checkResult(
|
||||||
entityBinding,
|
entityBinding,
|
||||||
|
@ -102,7 +102,7 @@ public class UnidirectionalOneToManyBindingTests extends BaseUnitTestCase {
|
||||||
Collection.class,
|
Collection.class,
|
||||||
simpleEntityBinding,
|
simpleEntityBinding,
|
||||||
entityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(),
|
entityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(),
|
||||||
Identifier.toIdentifier( "`theBagOwner`" ),
|
Identifier.toIdentifier( "theBagOwner" ),
|
||||||
FetchTiming.DELAYED
|
FetchTiming.DELAYED
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class UnidirectionalOneToManyBindingTests extends BaseUnitTestCase {
|
||||||
Set.class,
|
Set.class,
|
||||||
simpleEntityBinding,
|
simpleEntityBinding,
|
||||||
entityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(),
|
entityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(),
|
||||||
Identifier.toIdentifier( "`theSetOwner`" ),
|
Identifier.toIdentifier( "theSetOwner" ),
|
||||||
FetchTiming.IMMEDIATE
|
FetchTiming.IMMEDIATE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class UnidirectionalOneToManyBindingTests extends BaseUnitTestCase {
|
||||||
Collection.class,
|
Collection.class,
|
||||||
simpleEntityBinding,
|
simpleEntityBinding,
|
||||||
(SingularAttributeBinding) entityBinding.locateAttributeBinding( "name" ),
|
(SingularAttributeBinding) entityBinding.locateAttributeBinding( "name" ),
|
||||||
Identifier.toIdentifier( "`ownerName`" ),
|
Identifier.toIdentifier( "ownerName" ),
|
||||||
FetchTiming.EXTRA_DELAYED
|
FetchTiming.EXTRA_DELAYED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue