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 Daniel Spitzer <ak...@yahoo.de> on 2004/07/02 11:03:13 UTC

Collection on Non-Primarykey Field

Hi list,

heres the problem:
I have two Entites mapping on two tables and want
the one of them to have a collection of the other
tables' elements, but the key is not the primarykey
of the collection-holding class, but another Field?

For Example:

<class-descriptor 
  class="Master"
  table="Master"
>
  <field-descriptor 
    name="master1"
    column="master1"
    jdbc-type="INTEGER"
    primarykey="true"
  />
  <field-descriptor 
    name="master2"
    column="master2"
    jdbc-type="INTEGER"
  />
  <collection-descriptor
    name="collSlaves"
    element-class-ref="slave"
  >
    <inverse-foreignkey field-ref="slave2"/>
  </collection-descriptor>
</class-descriptor>

<class-descriptor 
  class="Slave"
  table="Slave"
>
  <field-descriptor
    name="slave1"
    column="slave1"
    jdbc-type="INTEGER"
  />
  <field-descriptor 
    name="slave2"
    column="slave2"
    jdbc-type="INTEGER"
  />
</class-descriptor>

Now, I don't want the primarykey of Master to be
the key to get the slaves, but the Field master2.

How can this be accomplished?

My Guess would be something like this: 
  <collection-descriptor
    name="collSlaves"
    element-class-ref="slave"
  >
    <inverse-foreignkey field-ref="slave2"/>
    <foreignkey field-ref="master2"/>
  </collection-descriptor>

Well, this one didn't work out for me, of course ;)

Can anybody help me?

Greetings,
Gabor



	
		
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 100MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de

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