Search in sources :

Example 1 with LongIdentifierNamingStrategy

use of org.hibernate.test.annotations.namingstrategy.LongIdentifierNamingStrategy in project hibernate-orm by hibernate.

the class AbstractCharsetNamingStrategyTest method testWithCustomNamingStrategy.

@Test
public void testWithCustomNamingStrategy() throws Exception {
    Metadata metadata = new MetadataSources(serviceRegistry).addAnnotatedClass(Address.class).addAnnotatedClass(Person.class).getMetadataBuilder().applyImplicitNamingStrategy(new LongIdentifierNamingStrategy()).build();
    UniqueKey uniqueKey = metadata.getEntityBinding(Address.class.getName()).getTable().getUniqueKeyIterator().next();
    assertEquals(expectedUniqueKeyName(), uniqueKey.getName());
    org.hibernate.mapping.ForeignKey foreignKey = (org.hibernate.mapping.ForeignKey) metadata.getEntityBinding(Address.class.getName()).getTable().getForeignKeyIterator().next();
    assertEquals(expectedForeignKeyName(), foreignKey.getName());
    org.hibernate.mapping.Index index = metadata.getEntityBinding(Address.class.getName()).getTable().getIndexIterator().next();
    assertEquals(expectedIndexName(), index.getName());
}
Also used : LongIdentifierNamingStrategy(org.hibernate.test.annotations.namingstrategy.LongIdentifierNamingStrategy) UniqueKey(org.hibernate.mapping.UniqueKey) Metadata(org.hibernate.boot.Metadata) MetadataSources(org.hibernate.boot.MetadataSources) Test(org.junit.Test)

Aggregations

Metadata (org.hibernate.boot.Metadata)1 MetadataSources (org.hibernate.boot.MetadataSources)1 UniqueKey (org.hibernate.mapping.UniqueKey)1 LongIdentifierNamingStrategy (org.hibernate.test.annotations.namingstrategy.LongIdentifierNamingStrategy)1 Test (org.junit.Test)1