You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Oleg Nitz <on...@ukr.net> on 2003/01/05 17:21:37 UTC
OQL with attributes projections
Hi All,
I have changed the implementation of OQL queries with attributes projections,
so that
1) OJB doesn't load the whole objects in this case (as it did before)
2) multiple attributes are supported (I hope this feature is in accord with
ODMG spec)
3) "distinct" keyword is supported.
Code example follows (from ProjectionAttributeTest.java)
// Multiple attributes are returned in Object[]
query.create("select aPerson.firstname, aPerson.lastname from Person");
ManageableCollection result = (ManageableCollection) query.execute();
java.util.Iterator it = result.ojbIterator();
while (it.hasNext())
{
Object[] res = (Object[]) it.next();
String firstname = (String) res[0];
String lastname = (String) res[1];
}
// An attribute may belong to related object
query1.create("select distinct anArticle.productGroup.groupId from Article");
List result1 = (List) query1.execute();
for (it = result1.iterator(); it.hasNext(); )
{
Integer value = (Integer) it.next();
}
Regards,
Oleg