Search in sources :

Example 6 with NamingFactory

use of org.datanucleus.store.schema.naming.NamingFactory in project tests by datanucleus.

the class JPANamingFactoryTest method testJoinTableName.

public void testJoinTableName() {
    JPAEntityManagerFactory jpaEMF = (JPAEntityManagerFactory) emf;
    NucleusContext nucCtx = jpaEMF.getNucleusContext();
    ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
    MetaDataManager mmgr = nucCtx.getMetaDataManager();
    AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(UserGroup.class, clr);
    NamingFactory factory = new JPANamingFactory(nucCtx);
    factory.setNamingCase(NamingCase.LOWER_CASE);
    factory.setMaximumLength(SchemaComponent.TABLE, 128);
    String name = factory.getTableName(cmd1.getMetaDataForMember("members"));
    assertEquals("Join table name is incorrect", "usergroup_groupmember", name);
}
Also used : JPAEntityManagerFactory(org.datanucleus.api.jpa.JPAEntityManagerFactory) NucleusContext(org.datanucleus.NucleusContext) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) MetaDataManager(org.datanucleus.metadata.MetaDataManager) JPANamingFactory(org.datanucleus.store.schema.naming.JPANamingFactory) JPANamingFactory(org.datanucleus.store.schema.naming.JPANamingFactory) NamingFactory(org.datanucleus.store.schema.naming.NamingFactory) AbstractClassMetaData(org.datanucleus.metadata.AbstractClassMetaData)

Aggregations

NamingFactory (org.datanucleus.store.schema.naming.NamingFactory)6 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)5 MetaDataManager (org.datanucleus.metadata.MetaDataManager)5 JPANamingFactory (org.datanucleus.store.schema.naming.JPANamingFactory)5 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)4 NucleusContext (org.datanucleus.NucleusContext)4 JPAEntityManagerFactory (org.datanucleus.api.jpa.JPAEntityManagerFactory)4 ArrayList (java.util.ArrayList)1 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)1 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)1 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)1 RelationType (org.datanucleus.metadata.RelationType)1 DN2NamingFactory (org.datanucleus.store.schema.naming.DN2NamingFactory)1 TypeManager (org.datanucleus.store.types.TypeManager)1 MultiColumnConverter (org.datanucleus.store.types.converters.MultiColumnConverter)1 TypeConverter (org.datanucleus.store.types.converters.TypeConverter)1