assertEquals("Test", inst2.getValue("lastName"));
}
public void testReadAssocRelationalFKToVirtualCollection() throws Exception
{
Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
InstanceArrayList list;
Instance inst, inst2;
list = (InstanceArrayList)Query.createRead(relationalClass,
parse("(firstName (relFKToVirtColl scientificName))"),
parse("(= (@ lastName) \"Test\")"),
parse("((firstName . #f))"),
-1, 0, false, Query.SEC_NODE, m_context).read();
assertEquals(2, list.getCount());
inst = list.getInstance(0);
assertEquals("Zoe", inst.getValue("firstName"));
assertNull(inst.getValue("relFKToVirtColl"));
inst = list.getInstance(1);
assertEquals("Joe", inst.getValue("firstName"));
inst2 = (Instance)inst.getValue("relFKToVirtColl");
assertEquals("Felis catus", inst2.getValue("scientificName"));
assertEquals("Cat", inst2.getValue("commonName"));
// Read the reverse (the virtual collection)
Metaclass virtualClass = getMetadata().getMetaclass("Animal");
InstanceArrayList list2;
list = (InstanceArrayList)virtualClass.invoke("read", new Object[]{
parse("(commonName (virtCollFromRelFK firstName))"), null, null, null, null, null
});
assertEquals(4, list.size());
inst = list.getInstance(0);