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" <[email protected]>
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]