Assert.assertEquals(cols.get(0).getName(), "nt");
}
@Test(dependsOnMethods = "createSchema")
public void ref_simple() throws Exception {
PersistenceSession session = persistenceManager.createSession();
try {
ReferencedEntity inst = new ReferencedEntity();
inst.setId(1);
inst.setVal("1");
session.insert(inst);
ReferencedEntity loaded = session.loadOne(ReferencedEntity.class, 1);
Assert.assertNotNull(loaded);
Assert.assertEquals(loaded.getVal(), "1");
NextFlatComposite compNext = new NextFlatComposite();
compNext.setTs(new Date());
compNext.setValA(.42d);
SomeComposite comp = new SomeComposite();
comp.setStr("cstr");
comp.setVint(42);
comp.setNext(compNext);
SomeComposite compB = new SomeComposite();
compB.setStr("zyx");
compB.setVint(88);
compB.setNext(compNext);
ReferencingEntity ref = new ReferencingEntity();
ref.setId(2);
ref.setVal("v2");
ref.setReferencedEntity(loaded);
ref.setSomeComposite(comp);
ref.setCompB(compB);
session.insert(ref);
ReferencingEntity l = session.loadOne(ReferencingEntity.class, 2);
Assert.assertEquals(l.getId(), 2);
Assert.assertEquals(l.getVal(), "v2");
Assert.assertNotNull(l.getReferencedEntity());
Assert.assertEquals(l.getReferencedEntity().getId(), 1);
Assert.assertEquals(l.getReferencedEntity().getVal(), "1");
Assert.assertNotNull(l.getSomeComposite());
Assert.assertEquals(l.getSomeComposite().getStr(), "cstr");
Assert.assertEquals(l.getSomeComposite().getVint(), 42);
Assert.assertNotNull(l.getSomeComposite().getNext());
Assert.assertEquals(l.getSomeComposite().getNext().getTs(), compNext.getTs());
Assert.assertEquals(l.getSomeComposite().getNext().getValA(), .42d);
Assert.assertNotNull(l.getCompB());
Assert.assertEquals(l.getCompB().getStr(), "zyx");
Assert.assertEquals(l.getCompB().getVint(), 88);
Assert.assertNotNull(l.getCompB().getNext());
Assert.assertEquals(l.getCompB().getNext().getTs(), compNext.getTs());
Assert.assertEquals(l.getCompB().getNext().getValA(), .42d);
} finally {
session.close();
}
}