Thanks, but I was looking for something using ODMG-API, not PB-API. I did
find this test case and my query looks similar except that I have 2
different object types in my query.
/**
+ * test Subquery
+ * get all articles with price > avg(price)
+ * PROBLEM: avg(price) is NOT extent aware !!
+ *
+ * test may fail if db does not support sub queries
+ */
+ public void _testSubQuery1() throws Exception
+ {
+ Implementation odmg = OJB.getInstance();
+ Database db = odmg.newDatabase();
+ db.open(databaseName, Database.OPEN_READ_WRITE);
+
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
+
+ OQLQuery query = odmg.newOQLQuery();
+ query.create("select anArticle from " +
+ Article.class.getName() +
+ " where " +
+ " price >= (select avg(price) from " +
+ Article.class.getName() +
+ " where articleName like \"A%\") ");
+
+ List results = (List) query.execute();
+ tx.commit();
+ assertTrue(results.size() > 0);
+ db.close();
+ }
->-----Original Message-----
->From: Vasily Ivanov [mailto:[EMAIL PROTECTED]
->Sent: Thursday, March 23, 2006 9:22 PM
->To: OJB Users List
->Subject: Re: Subqueries in ODMG query
->
->http://db.apache.org/ojb/docu/guides/query.html#subqueries
->
->On 3/24/06, Eric Kelm <[EMAIL PROTECTED]> wrote:
->> Is it possible to use a subquery inside of an ODMG query e.g.
->>
->> select jobs from " + JobBO.class.getName(); where
->employees_idemployee
->> = " + employee.getIdEmployee(); idjob like $1 or idtask_code like
->> (select task_codes from " + TaskCodeBO.class.getName();
->> where task_code_name like $2
->> )
->>
->> If this is not correct syntax (seems not to be) can someone
->point me
->> in the right direction? Thanks
->>
->>
->>
->>
->---------------------------------------------------------------------
->> To unsubscribe, e-mail: [EMAIL PROTECTED]
->> For additional commands, e-mail: [EMAIL PROTECTED]
->>
->>
->
->---------------------------------------------------------------------
->To unsubscribe, e-mail: [EMAIL PROTECTED]
->For additional commands, e-mail: [EMAIL PROTECTED]
->
->
->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]