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 Hinnerk Feldwisch <di...@yahoo.de> on 2003/06/22 19:58:40 UTC

Those friends

Hello altogether,

as a newbie I ran into some trouble regarding a self- referential (?)
mapping: a User- Class shall have a Vector "friends" with other users.
I created a (mysql-) table "friends" where the relationship shall be
stored, with fields "theUserId" and "friendId", primary key is
(theUserId, friendId).

My repository_user contains the following:

   <class-descriptor
      class="org.rolli.user.User"
      table="USERS"
   >
      <field-descriptor id="1"
         name="userId"
         column="userId"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"
      />
     (...)
      <collection-descriptor
         name="friends"
         element-class-ref="org.rolli.user.User"
         auto-retrieve="false"
         auto-update="false"
         indirection-table="friends"
      >
         <fk-pointing-to-this-class column="theUserId"/>
         <fk-pointing-to-element-class column="friendId"/>
      </collection-descriptor>
   </class-descriptor>


The problem is that I get the error
  java.sql.SQLException: General error: Column: 'theUserId' in where clause is ambiguous
when retrieving the friends by
  broker.retrieveReference(user, "friends");

What's the course of that? Any hint?

Thank you quite much!,
 Hinnerk

P.S.: Regarding my problem 1-2 weeks ago: the character- set is
correct by defining the field as VARCHAR instead of LONGVARCHAR - the
latter seam to have a faulty character- conversion?!
Thank you for your answers to this questions!