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 th...@etu.unige.ch on 2005/06/08 14:08:04 UTC

Oracle exception: column ambiguously defined - need help

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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Oracle exception: column ambiguously defined - need help

Posted by Jakob Braeuchi <jb...@gmx.ch>.
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

thomas0@etu.unige.ch 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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

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