ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tino Wildenhain <>
Subject Re: Query on multiple tables
Date Mon, 08 Aug 2005 08:33:01 GMT
Am Montag, den 08.08.2005, 10:10 +0200 schrieb Dennis Riedel:
> Hello
> I am new to OJB and asking myself, how to query multiple tables using 
> the persistenceBroker.
> I cannot follow the example given on the OJB Query Page, I don`t 
> understand it.
> I have three tables and all contain one column 'area_id'. I want to find 
> all entries in all tables containing a specific area_id, e.g. '2'.
> So I think joining them would be the idea.
> When I expect one resulting object of that query (there can be only one 
> result, that is a fact), of which type will this be?
> I workd with DAO Classes to recieve a special object or a collection of 
> special objects.
> But how is it, when I query on three tables, representing three 
> different objects? Do I need a wrapper? Should these three objects 
> implement the same interface to 'encapsulate' or 'wrap' the resulting 
> object?
> With my actual knowledge I would query each table with its DAO but that 
> would be three queries to get the result.
> I want one query.

Yes, wrong list :-)
But what you want is usually done with UNION

SELECT a,b FROM table1 WHERE ...
SELECT a,b FROM table2 WHERE ...

There is UNION ALL, EXCEPT, INTERSECT... see your favourite
SQL manual for details
Tino Wildenhain <>

View raw message