Thanks a lot Jakob!
That was the problem....

-----Ursprüngliche Nachricht-----
Von: Jakob Braeuchi [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 13. März 2006 18:09
An: OJB Users List
Betreff: Re: AW: Problem joining two tables with same column name

hi josef,

you should not prefix the attribute with the tablename.
crit.addEqualTo("id") is ok, where id is the name of the attribute not 
the name of the column.

hth
jakob

Josef Wagner schrieb:
> Hi Jakob,
> 
> do you think that I have the same problem?
> It appears only with m-n.
> 
> ##################
> ### 1. mapping ###
> ##################
>   <!-- m - n -->
>   <collection-descriptor
>      name="table_n"
>  
>
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList
> "
>      element-class-ref="de.on_ergy.lakon.data.model.TableN"
>      auto-retrieve="true"
>      auto-update="object"
>      auto-delete="link"
>      proxy="true"
>      indirection-table="table_m_table_n"
>   >
>      <fk-pointing-to-this-class column="table_m_obj_id"/>
>      <fk-pointing-to-element-class column="table_n_obj_id"/>
>   </collection-descriptor>
> 
> #############################
> ### 2. javacode for query ###
> #############################
> 
> crit.addEqualTo("table_n.obj_id", 1);
> 
> #########################
> ### 3. ojb sql output ###
> #########################
> SELECT A0.obj_id,....
> FROM table_m A0 
> LEFT OUTER JOIN 
> (
> table_m_table_n A1 LEFT OUTER JOIN table_n A2 
> ON A1.table_n_obj_id=A2.obj_id
> ) 
> ON A0.obj_id=A1.table_m_obj_id 
> WHERE obj_id = 1
> 
> 
> ##################
> ### 4. the bug ###
> ##################
> Now, the problem is the incorrect obj_id without A2 as prefix :o(.
> So, I get the following logical exception:
> org.postgresql.util.PSQLException: ERROR: column reference "obj_id" is
> ambiguous
> 
> 
> Thanks a lot!
> 
> Josef Wagner
> 
> 
> 
> -------- Original-Nachricht --------
> Betreff:      Re: AW: Problem joining two tables with same column name
> Datum:        Fri, 03 Mar 2006 19:03:50 +0100
> Von:  Jakob Braeuchi <[EMAIL PROTECTED]>
> Antwort an:   OJB Users List <[email protected]>
> An:   OJB Users List <[email protected]>, [EMAIL PROTECTED]
> Referenzen: 
> <[EMAIL PROTECTED]>
> 
> 
> 
> hi markus,
> 
> ojb 1.0.5 should be released this month.
> 
> you should always use 'attributes' not 'columns' in your queries and let 
> ojb translate the attribut-name into a column-name.
> 
> hth
> jakob
> 
> ps: what do you use ojb for in bedag ?
> 
> 
> Lauber Markus, Bedag schrieb:
> 
>>Hi Jakob
>>
>>Thank you for the explanation. When will OJB 1.0.5 be released? 
>>
>>What do you suggest, is it better to use the method addEqualTo() or
>>addColumnEqualTo() in a project? In our project we used both methods and
>>we want to refactor our code.
>>
>>Greetings
>>Markus 
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>No virus found in this incoming message.
>>Checked by AVG Free Edition.
>>Version: 7.1.375 / Virus Database: 268.1.2/274 - Release Date: 03.03.2006
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



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

Reply via email to