Search in sources :

Example 6 with JPAEntityManagerFactory

use of org.datanucleus.api.jpa.JPAEntityManagerFactory 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

JPAEntityManagerFactory (org.datanucleus.api.jpa.JPAEntityManagerFactory)6 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)4 NucleusContext (org.datanucleus.NucleusContext)4 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)4 MetaDataManager (org.datanucleus.metadata.MetaDataManager)4 JPANamingFactory (org.datanucleus.store.schema.naming.JPANamingFactory)4 NamingFactory (org.datanucleus.store.schema.naming.NamingFactory)4 Map (java.util.Map)1 AttributeNode (javax.persistence.AttributeNode)1 EntityManager (javax.persistence.EntityManager)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 EntityTransaction (javax.persistence.EntityTransaction)1 PersistenceException (javax.persistence.PersistenceException)1 Subgraph (javax.persistence.Subgraph)1 FetchGroup (org.datanucleus.FetchGroup)1 PersistenceNucleusContext (org.datanucleus.PersistenceNucleusContext)1 JPAEntityGraph (org.datanucleus.api.jpa.JPAEntityGraph)1 Person (org.datanucleus.samples.annotations.models.company.Person)1 VersionedPerson (org.datanucleus.samples.annotations.versioned.VersionedPerson)1