tags:

views:

23

answers:

1

I have a table which needs a relationship over itself.

Table Example:

field_PK ---> Primary key 
field_A ---> used as Foreign key to field_B 
field_B

Mapping:

  <id name="field_PK">
      <generator class="assigned"/>
  </id>

    ......

  <bag name="childs">
      <key column="field_A"  update="false"/>
      <one-to-many class="example"/>
  </bag>

 </class>
</hibernate-mapping>

I've noticed that by default NH uses the PK to perform joins... How can I tell NH to join field_A on field_B (instead of joining field_A on the PK)?

+1  A: 

You can use the property-ref attribute to join to any mapped property.

Diego Mijelshon
thank you, it works!
caifa