Dennis Riedel wrote:
Carlos Chávez wrote:
Dennis Riedel wrote:
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.
Thanks for any support on querying multiple tables.
Hi Dennis.
you can use too ReportQueryByCriteria.
for example:
make criteria:
Crit criterio = new Criteria();
crit.addEqualTo("area_id", new Integer(2));
Create the Query:
ReportQueryByCriteria query = new ReportQueryByCriteria(Table1.class,
crit);
then you need to tell what fields you want in the result:
query.setAttributes(new String[] { "fieldName",
"pathToField.fieldName", "pathToField.fieldName"});
later you can obtain a collection of object[] where each item of the
array are each field, each item have a datatype equal to each field:
Iterator iter = broker.getReportQueryIteratorByQuery(query)
Then you can access to rows of the result.
Cheers.
Carlos Chávez.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Thanks alot for your answer Carlos.
When I get you right, you query on one table (Table1.class in your
example). Is there any possibility to query on more than one table
with one query by the same criteria as posted above?
Hi Dennis.
Well, you know there is a relationship between tables, in you
repository that relationship are configured by a reference-descriptor or a
collection-descriptor, you can use that names for navigate over the
object in the object relationships, so, when i'm say
"pathToField.fieldName",
i'm trying to show the way to access the other fields in other
tables using the reference-descriptor or collection-descriptor. In
theory the example
that i'm show you can query over multiple tables.
Cheers
Carlos Chávez.
Regards,
Dennis
---------------------------------------------------------------------
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]