You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Dirk Manske (Service Respond)" <se...@nexgo.de> on 2004/02/01 23:48:44 UTC

How to setup this query with OJB-PB

Hi,

I am using PB API and have two classes Activity and Schedule with 1:N
association. Both are declared in the repository-user.xml with a
collection-descriptor as reference.  Now I want to process a query which
results in a collection with all activities where no schedule has been set.
I have read the Query examples carefully but I just don't get it. Could
someone help me with the following sql statement:

SELECT * FROM Activity As act

WHERE act.ACTIVITY_ID NOT IN

(SELECT ACTIVITY_ID FROM SCHEDULE);


Looks so simple, but I cannot figure it out. How to set up this statement
using the Criteria class?

Hope someone can help. thanks,

Dirk


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: How to setup this query with OJB-PB

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi dirk,


         ReportQueryByCriteria subQuery;
         Criteria subCrit = new Criteria();
         Criteria crit = new Criteria();

         subQuery = QueryFactory.newReportQuery(Schedule.class, subCrit);
         subQuery.setColumns(new String[] { "activityId" });

         crit.addNotIn("activityId", subQuery);
         Query q = QueryFactory.newQuery(Activity.class, crit);

         results = broker.getCollectionByQuery(q);

for a working sample please have a look at QueryTest#testSubQuery2.

hth
jakob

Dirk Manske (Service Respond) wrote:
> Hi,
> 
> I am using PB API and have two classes Activity and Schedule with 1:N
> association. Both are declared in the repository-user.xml with a
> collection-descriptor as reference.  Now I want to process a query which
> results in a collection with all activities where no schedule has been set.
> I have read the Query examples carefully but I just don't get it. Could
> someone help me with the following sql statement:
> 
> SELECT * FROM Activity As act
> 
> WHERE act.ACTIVITY_ID NOT IN
> 
> (SELECT ACTIVITY_ID FROM SCHEDULE);
> 
> 
> Looks so simple, but I cannot figure it out. How to set up this statement
> using the Criteria class?
> 
> Hope someone can help. thanks,
> 
> Dirk
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org