Search in sources :

Example 1 with SubBase

use of org.datanucleus.samples.metadata.inh2.SubBase in project tests by datanucleus.

the class BasicTest method testInh2.

public void testInh2() {
    try {
        PersistenceManager pm = pmf.getPersistenceManager();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            Base base1 = new Base(1, "b1");
            Base base2 = new Base(2, "b2");
            Base base3 = new Base(3, "b3");
            SubBase group1 = new SubBase(4, "b4", "SB1");
            SubBase group2 = new SubBase(5, "b5", "SB2");
            Container c = new Container(new Base[] { base1, base2, base3, group1, group2 });
            pm.makePersistent(c);
            tx.commit();
            tx.begin();
            Collection col = (Collection) pm.newQuery(SubBase.class).execute();
            assertTrue(col.size() == 2);
            assertTrue(col.contains(group1));
            assertTrue(col.contains(group2));
            tx.commit();
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            pm.close();
        }
    } finally {
        clean(Container.class);
        clean(SubBase.class);
        clean(Base.class);
    }
}
Also used : SubBase(org.datanucleus.samples.metadata.inh2.SubBase) Container(org.datanucleus.samples.metadata.inh2.Container) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) Collection(java.util.Collection) Base(org.datanucleus.samples.metadata.inh2.Base) SubBase(org.datanucleus.samples.metadata.inh2.SubBase)

Aggregations

Collection (java.util.Collection)1 PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 Base (org.datanucleus.samples.metadata.inh2.Base)1 Container (org.datanucleus.samples.metadata.inh2.Container)1 SubBase (org.datanucleus.samples.metadata.inh2.SubBase)1