karlchu wrote:
I believe this will solve your problem:
Code:
<join table="Ubicazioni" optional="true">
The documentation for <join> in NHibernate is not completed. You may use the Hibernate docs for now.
Thanks karlchu, this worked out, but I think there's a problem.
I have one object described by this mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Anagrafica, it.telecomitalia.Gecko.BusinessEntities" table="Anagrafiche" lazy="false">
<id name="AnagraficaID" column="AnagraficaID">
<generator class="identity" />
</id>
<join table="Ubicazioni">
<key column="UbicazioneID"/>
<property name="Ubicazione" column="Description" type="string"/>
</join>
</class>
</hibernate-mapping>
In code:
public class Anagrafica
{
private long anagraficaID;
// element on which i would like to make the join table
private string ubicazione;
......
So I have one table for Ubicazione with two columns UbicazioneID and Description and one table for Anagrafica class with a foreign key UbicazioneID.
When I try to test the join table attribute it seems that nhibenrate make the join on the Anagrafica PK instead of the FK as I can see from the logs:
SELECT anagrafica0_.AnagraficaID as Anagrafi1_2_1_ FROM Anagrafiche anagrafica0_ inner join Ubicazioni anagrafica0_1_ on anagrafica0_.AnagraficaID=anagrafica0_1_.UbicazioneID.
I think that the join clause anagrafica0_.AnagraficaID=anagrafica0_1_.UbicazioneID
should be
anagrafica0_.UbicazioneID=anagrafica0_1_.UbicazioneID
Am i wrong?
Kind regards
Massimo Ugues