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 jefferson chaves gomes <je...@amhpdf.com.br> on 2005/04/20 20:48:15 UTC

OJB queries.....

 Hi, I'm from Brazil, then it forgives my English, I want to use OJB and divulge it in Brazil, but I have a problem ......

   How I can do a querie with more than one table.
   For example(this example was removed of your site OK):

I know that this reply it is in the site: http://db.apache.org/ojb/docu/guides, but I am not understanding.
Please, you can say me as to make this example below since the beginning, or either,
with the mapping of the archive repository_database.xml and  the necessary classes .java for I make it  ?????


SELECT DISTINCT A0.ID, A1.VALUEFROM CONTAINER A0 INNER JOIN ABSTRACT_ATTRIBUTE A1     ON A0.ID=A1.REF_ID     INNER JOIN ABSTRACT_ATTRIBUTE A2     ON A0.ID=A2.REF_ID     INNER JOIN ABSTRACT_ATTRIBUTE A3     ON A0.ID=A3.REF_IDWHERE (( A0.NAME =  'companyName' ) AND  (A0.VALUE =  'iBanx' )) AND      (( A1.NAME =  'contactPerson' ) AND  (A1.VALUE LIKE '%janssen%' )) AND      (( A2.NAME =  'size' ) AND  (A2.VALUE =  '500' ))
 My main doubt is: How to work with more than with one table ?
 This because to use one table in the querie for me is not problem OK?
 Please, help me to learn and to divulge this framework here in Brazil
-- 
Jefferson Chaves 

Re: OJB queries.....

Posted by "Robert r. Sanders" <ro...@ipov.net>.
If I understand your question:

Since OJB is a object-to-relational mapping framework this is done in steps:
    First you map the java classes that you want to store to the 
database tables and columns  using the repository.xml
    Second you query using one of the OJB APIs; the query is for the 
Java Object you want, and references Objects, Fields, etc... not tables 
and columns.
    Then OJB translates your query into SQL, runs the SQL, and 
constructs Objects from the returns values.
    So, if what you want to do is run a query that joins multiple 
tables, then setting up the repository.xml correctly should be all you 
need to do.

If you are asking how to map one class onto multiple tables then the 
section of the docs at 
http://db.apache.org/ojb/docu/guides/advanced-technique.html#Mapping+Classes+on+Multiple+Joined+Tables  
explains it (partially).

If this doesn't help, then please try rephrasing your question and maybe 
I will be able to understand it better.




jefferson chaves gomes wrote:

> Hi, I'm from Brazil, then it forgives my English, I want to use OJB and divulge it in Brazil, but I have a problem ......
>
>   How I can do a querie with more than one table.
>   For example(this example was removed of your site OK):
>
>I know that this reply it is in the site: http://db.apache.org/ojb/docu/guides, but I am not understanding.
>Please, you can say me as to make this example below since the beginning, or either,
>with the mapping of the archive repository_database.xml and  the necessary classes .java for I make it  ?????
>
>
>SELECT DISTINCT A0.ID, A1.VALUEFROM CONTAINER A0 INNER JOIN ABSTRACT_ATTRIBUTE A1     ON A0.ID=A1.REF_ID     INNER JOIN ABSTRACT_ATTRIBUTE A2     ON A0.ID=A2.REF_ID     INNER JOIN ABSTRACT_ATTRIBUTE A3     ON A0.ID=A3.REF_IDWHERE (( A0.NAME =  'companyName' ) AND  (A0.VALUE =  'iBanx' )) AND      (( A1.NAME =  'contactPerson' ) AND  (A1.VALUE LIKE '%janssen%' )) AND      (( A2.NAME =  'size' ) AND  (A2.VALUE =  '500' ))
> My main doubt is: How to work with more than with one table ?
> This because to use one table in the querie for me is not problem OK?
> Please, help me to learn and to divulge this framework here in Brazil
>  
>

-- 
    Robert r. Sanders
    Chief Technologist
    iPOV
    (334) 821-5412
    www.ipov.net


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