Thanks for correcting my wrong use of criterias.

Unfortunately this doesn't solve my problem.

Let me explain my situation with more details. 

I want to model a filesystem with java classes.

First there's the Element class. Then there's the Fichier (File in french)
class
and the Folder class who inherits from Element.

I want the Folder class to have a collection of Fichiers and a collection of
Folders to represent the Elements contained in each folder.

I want also to do a cross-link by having a collection in the Element class to
represent the list of containers for an Element.

Here's an image of the structure: 
http://www.ashtom.net/img/objectLayerStructure.gif

Here's a representation of the database structure:
http://www.ashtom.net/img/database_model.gif

Here's the repository who fits at best with what I want to represent with my
model: 
http://www.ashtom.net/files/not_working_repository.xml

Unfortunately, this repository raises an Oracle exception (ORA-00918: column
ambiguously defined).

On the second hand, this configuration below works but it doesn't allow to my
application to differentiate a Folder from a Fichier:
http://www.ashtom.net/files/working_repository.xml

I know this is a lot of trouble but I really don't know how to solve this
problem.

Thanks a lot for your help !

Alexandre

----- Original Message ----- 
From: "Jakob Braeuchi" <[EMAIL PROTECTED]>
To: "OJB Users List" <ojb-user@db.apache.org>
Sent: Friday, June 10, 2005 6:18 PM
Subject: Re: Oracle exception: column ambiguously defined - need help


> hi thomas,
> 
> if the attribute is named 'InRoot' then you should use this name in the 
> query and not the name of the column !
> 
> jakob
> 
> [EMAIL PROTECTED] schrieb:
>> Thanks for answering me,
>> 
>> The two m:n relations from are here because I wanted my application (a JSF 
>> application) to differentiate a "matis.component.filemanager.Fichier" from a

>> "matis.component.filemanager.Folder", so I can use methods specific to each
>> class.
>> For the query part, there's actually a "InRoot" attribute (a boolean)
described
>> in my repository in the
>> "matis.component.filemanager.Element" (which is the parent class of Fichier
and
>> Folder) class descriptor. 
>> 
>> extract of Element class descriptor:
>> 
>>       <field-descriptor
>>          name="InRoot"
>>          column="INROOT"
>>          jdbc-type="INTEGER"
>>         
>>
conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"/>
>> 
>> How could I build a query with this attribute (as it is a boolean I don't
know
>> how to compare InRoot with a boolean).
>> 
>> Thanks again for your help,
>> 
>> Alexandre
>> 
>> 
>> ----- Original Message ----- 
>> From: "Jakob Braeuchi" <[EMAIL PROTECTED]>
>> To: "OJB Users List" <ojb-user@db.apache.org>
>> Sent: Wednesday, June 08, 2005 6:56 PM
>> Subject: Re: Oracle exception: column ambiguously defined - need help
>> 
>> 
>> 
>>>hi alexandre,
>>>
>>>the mapping looks a little strange to me. From Folder you have two m:n 
>>>relationships pointing to different classes, but both use the same 
>>>indirection table. another thing is the attribute 'INROOT' in the 
>>>criteria. there's no such attribute defined in the class-descriptor of 
>>>class 'Folder'. the attributes used in a query are usually attributesof 
>>>the class not columns.
>>>
>>>jakob
>>>
>>>[EMAIL PROTECTED] schrieb:
>>>
>>>>Hello,
>>>>
>>>>My name is Alexandre and I'm a student in the University of Geneva in the
>>>>Information Systems departement.
>>>>
>>>>I'm currently working on a web application using an OJB layer. I have a
>>>>problem of column ambiguously defined when querying my Oracle Database
>> 
>> through
>> 
>>>>OJB's QueryFactory method. I read Jakob Braeuchi's  answer to Naveen
>> 
>> regarding
>> 
>>>>column prefixes.
>>>>Unfortunately, I didn't quite understand his solution: how can I base
>> 
>> columns
>> 
>>>>on
>>>>attributes?
>>>>
>>>>here is the method querying the database:
>>>>
>>>>PersistenceBroker broker =
>>>>PersistenceBrokerFactory.defaultPersistenceBroker();
>>>>        Collection rootelements = null;
>>>>        Criteria crit = new Criteria();
>>>>        crit.addEqualTo("INROOT","1");
>>>>        Query q = QueryFactory.newQuery(Folder.class, crit);        
>>>>        try{
>>>>            rootelements = broker.getCollectionByQuery(q);
>>>>        }
>>>>        catch(PersistenceBrokerException e)
>>>>        {
>>>>            e.printStackTrace();
>>>>            if(broker != null) broker.abortTransaction();
>>>>        }
>>>>        finally
>>>>        {
>>>>            if (broker != null) broker.close();
>>>>        }
>>>>
>>>>And here is the part of the relevant repository:
>>>>
>>>>  <class-descriptor
>>>>    schema="FM"   
>>>>    class="matis.component.filemanager.Folder" 
>>>>    table="FOLDER">
>>>>    
>>>>      <field-descriptor
>>>>         name="id_Elem"
>>>>         column="ID_FOLDER"
>>>>         jdbc-type="INTEGER"
>>>>         primarykey="true"/>
>>>>      
>>>>       <collection-descriptor
>>>>         name="fichiersContained" 
>>>>
>> 
>>
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
>> 
>>>>         element-class-ref="matis.component.filemanager.Fichier"
>>>>         auto-retrieve="true"
>>>>         auto-update="true"
>>>>         auto-delete="true"
>>>>         indirection-table="INFOLD">
>>>>         <fk-pointing-to-this-class column="FOL_ID_ELEMENT"/>
>>>>         <fk-pointing-to-element-class column="ID_ELEMENT"/>
>>>>       </collection-descriptor>
>>>>      
>>>>       <collection-descriptor
>>>>         name="foldersContained" 
>>>>
>> 
>>
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
>> 
>>>>         element-class-ref="matis.component.filemanager.Folder"
>>>>         auto-retrieve="true"
>>>>         auto-update="true"
>>>>         auto-delete="true"
>>>>         indirection-table="INFOLD">
>>>>         <fk-pointing-to-this-class column="FOL_ID_ELEMENT"/>
>>>>         <fk-pointing-to-element-class column="ID_ELEMENT"/>
>>>>       </collection-descriptor>
>>>>       
>>>>       <reference-descriptor name="super"
>>>>         class-ref="matis.component.filemanager.Element"
>>>>         auto-retrieve="true"
>>>>         auto-update="true"
>>>>         auto-delete="true">
>>>>        <foreignkey field-ref="id_Elem"/>
>>>>    </reference-descriptor>
>>>>    
>>>>   </class-descriptor>
>>>>
>>>>When logging OJB's activity, I can see the query who raises the Oracle
>>>>exception (ORA-00918: column ambiguously defined), here it is:
>>>>
>>>>SELECT A0.ID_FOLDER 
>>>>FROM FM.FOLDER A0,INFOLD,FM.element A1,INFOLD 
>>>>WHERE A0.ID_FOLDER=A1.ID_ELEMENT 
>>>>AND ((INFOLD.FOL_ID_ELEMENT IN (?,?,?)) 
>>>>AND A0.ID_FOLDER = INFOLD.ID_ELEMENT)
>>>>
>>>>I'm a bit lost since it's my first time using OJB (I hope it's not the
>>>>last).
>>>>
>>>>Thanks a lot for reading my request and thanks in advance for your help.
>>>>
>>>>Yours Sincerely,
>>>>
>>>>Alexandre Thomas



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

Reply via email to