Search in sources :

Example 6 with Persistence

use of org.eclipse.jpt.jpa.core.context.persistence.Persistence in project jbosstools-hibernate by jbosstools.

the class HibernateJpaModelTests method testDefaultMapping.

@Test
public void testDefaultMapping() {
    assertNotNull(jpaProject);
    JpaContextRoot rootContextNode = jpaProject.getContextRoot();
    Persistence p = rootContextNode.getPersistenceXml().getRoot();
    assertTrue(p.getPersistenceUnitsSize() > 0);
    assertTrue(p.getPersistenceUnits().iterator().next() instanceof HibernatePersistenceUnit);
    HibernatePersistenceUnit hpu = (HibernatePersistenceUnit) p.getPersistenceUnits().iterator().next();
    List<ClassRef> crs = IterableTools.list(hpu.getClassRefs());
    assertTrue(crs.size() == 2);
    if (crs.get(0).isFor("entity.ManyToMany1")) {
        checkManyToMany1(crs.get(0));
        checkManyToMany2(crs.get(1));
    } else {
        checkManyToMany1(crs.get(1));
        checkManyToMany2(crs.get(0));
    }
}
Also used : JpaContextRoot(org.eclipse.jpt.jpa.core.context.JpaContextRoot) Persistence(org.eclipse.jpt.jpa.core.context.persistence.Persistence) ClassRef(org.eclipse.jpt.jpa.core.context.persistence.ClassRef) HibernatePersistenceUnit(org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit) Test(org.junit.Test)

Aggregations

Persistence (org.eclipse.jpt.jpa.core.context.persistence.Persistence)6 HibernatePersistenceUnit (org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit)5 JpaContextRoot (org.eclipse.jpt.jpa.core.context.JpaContextRoot)4 Test (org.junit.Test)4 MappingFileRef (org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)3 ClassRef (org.eclipse.jpt.jpa.core.context.persistence.ClassRef)2 PersistenceUnit (org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit)2 PersistenceXml (org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml)2 GenericOrmXml (org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml)2 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)2 OrmPersistentType (org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType)1 XmlPersistence (org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence)1 XmlPersistenceUnit (org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit)1 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)1