[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    AW: AW: Problem joining two tables with same column name
From:       "Josef Wagner" <josef.wagner () on-ergy ! de>
Date:       2006-03-14 7:44:33
Message-ID: OF4D3659CF.5CF449C3-ONC1257131.002A877A () on-ergy ! lan
[Download RAW message or body]

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


-----Ursprüngliche Nachricht-----
Von: Jakob Braeuchi [mailto:jbraeuchi@gmx.ch] 
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 <jbraeuchi@gmx.ch>
> Antwort an: 	OJB Users List <ojb-user@db.apache.org>
> An: 	OJB Users List <ojb-user@db.apache.org>, Markus.Lauber@bedag.ch
> Referenzen: 
> <D8EDCFCBA249554AB7DE58CC0FD90857B3A711@A99A-EMS-01VS1.ad.bedag.ch>
> 
> 
> 
> 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: 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
> 
> 

---------------------------------------------------------------------
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic