Thank you all for your kindness and answers to my 2 last questions !
Christine, that was exactly the problem...
And thank you Tom for the link to p6Spy...
 
Cécile

Christine Gerstenmayer <[EMAIL PROTECTED]> a écrit :
Hello Cecile,
I think, your coding is right.
But I got this exception at another problem: I didn't define a primary key
at one of my related tables.
When I regard your repository I see two primary keys in your table FONCTION.
Maybe this is the problem similar to my problem.
Sorry, but I don't know how to solve this, if these two primary keys are
required. But maybe someone of the others knows that.

Best regards,
Christine


-----Ursprüngliche Nachricht-----
Von: Cornillon Cecile [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 20. Juli 2005 16:52
An: OJB users List
Betreff: Joins on several tables (at least 3)

Hello,

I am just starting with OJB, and I haven't found the answer to the following
question in neither the archives neither the tutorials... (there was a
pretty similar question back in February 2005 (
"Using join-queries to build up (complex) object trees") but I have not
found an answer in the archives ....)

Basically what I am trying to achieve is the following : 
SELECT Domain.IDDOM 
FROM Context, Fonction, Domain
WHERE Context.IDCTXT=266353
AND Context.IDFONCTION=Fonction.IDFONCTION
AND Fonction.IDDOM=Domain.IDDOM


with the following 3 tables :
Domain : 
idDom (primary key) 
codeDom 
libDom 
....

Fonction : 
idFonction (primary key)
codeFonction 
libFonction 
idDom (foreign key to table Domain)
...

Context :
idCtxt (primary key) 
idFonction (foreign key to table Fonction)
...

One domain can be linked to several fonctions (1:n)
One fonction can be linked to several contexts (1:n)

I want to get the domain associated to one specific context, via the foreign
keys.


My Java method is the following :


PersistenceBroker broker = null;
Criteria crit = new Criteria();
crit.addEqualTo("listeFonctions.listeContextes.idCtxt", new
Integer(idCtxt)); 
QueryByCriteria query = new QueryByCriteria(Domain.class, crit);
log.debug("query.toString() = " + query.toString());
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
Collection domaines = broker.getCollectionByQuery(query);
I get 
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$Join.appendJoinEqual
ities(SqlQueryStatement.java:2055)
Am I using the right request ? ("listeFonctions.listeContextes.idCtxt" ?)



For information, my repository is the following :

table="FONCTION">
jdbc-type="INTEGER" nullable="false" primarykey="true" />
jdbc-type="INTEGER" />
jdbc-type="VARCHAR" />
jdbc-type="VARCHAR" />
jdbc-type="VARCHAR" />
jdbc-type="INTEGER" nullable="false" indexed="true" primarykey="true" />
name="listeContextes"
element-class-ref="com.inetpsa.infotec.sht.dtb.Context"
proxy="false"
auto-retrieve="true"
auto-delete="false"
auto-update="false"
>





jdbc-type="INTEGER" nullable="false" primarykey="true" />

jdbc-type="VARCHAR" />

jdbc-type="VARCHAR" />

/>
name="listeFonctions"
element-class-ref="com.inetpsa.infotec.sht.dtb.Fonction"
proxy="false"
auto-retrieve="true"
auto-delete="false"
auto-update="false"
>




table="CONTEXT" >
jdbc-type="INTEGER" nullable="false" primarykey="true" />
jdbc-type="INTEGER" nullable="false" indexed="true"
primarykey="true" />
jdbc-type="INTEGER" nullable="false" indexed="true"
primarykey="true" />
jdbc-type="INTEGER" nullable="false" indexed="true"
primarykey="true" />


Thanks a lot for your time and help ...

Cécile





---------------------------------
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici ! 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


                
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  

Reply via email to