Search in sources :

Example 1 with OrmPersistentType

use of org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType in project jbosstools-hibernate by jbosstools.

the class HibernateJpaOrmModelTests method testDefaultMapping.

@Test
public void testDefaultMapping() {
    assertNotNull(jpaProject);
    JpaContextRoot rootContextNode = jpaProject.getContextRoot();
    Persistence p = rootContextNode.getPersistenceXml().getRoot();
    assertTrue(p.getPersistenceUnits().iterator().hasNext());
    assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
    HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
    List<MappingFileRef> mfrs = IterableTools.list(hpu.getMappingFileRefs());
    assertTrue(mfrs.size() == 1);
    assertTrue(mfrs.get(0).getMappingFile() instanceof GenericOrmXml);
    GenericOrmXml orm = (GenericOrmXml) mfrs.get(0).getMappingFile();
    List<OrmPersistentType> pTypes = IterableTools.list(orm.getRoot().getPersistentTypes());
    assertTrue(pTypes.size() == 3);
    checkManyToMany1(orm.getRoot().getPersistentType("entity.ManyToMany1"));
    checkManyToMany2(orm.getRoot().getPersistentType("entity.ManyToMany2"));
}
Also used : JpaContextRoot(org.eclipse.jpt.jpa.core.context.JpaContextRoot) Persistence(org.eclipse.jpt.jpa.core.context.persistence.Persistence) OrmPersistentType(org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType) GenericOrmXml(org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml) HibernatePersistenceUnit(org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit) MappingFileRef(org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef) Test(org.junit.Test)

Aggregations

JpaContextRoot (org.eclipse.jpt.jpa.core.context.JpaContextRoot)1 OrmPersistentType (org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType)1 MappingFileRef (org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)1 Persistence (org.eclipse.jpt.jpa.core.context.persistence.Persistence)1 GenericOrmXml (org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml)1 HibernatePersistenceUnit (org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit)1 Test (org.junit.Test)1