I'm using Hibernate version 3.2
I have a database with 3 tables: A, B and A_B
Now I need to execute this query:
select from A, B, A_B, where A.id=A_B.id and B.cf=A_B.cf
I've created a class with all the fields, but don't know how to map the class.
I've tried this
<hibernate-mapping>
<class name="it.studio.model.ProgImpModel" table="Allocazione">
<composite-id>
<key-property name="aid" column="id"></key-property>
<key-property name="acf" column="cf"></key-property>
</composite-id>
<join table="Progetto" inverse="true">
<key column="id"></key>
<property name="pnome" column="nome"></property>
<property name="capo"></property>
<property name="descrizione"></property>
</join>
<join table="Impiegato">
<key column="cf" foreign-key="cf"></key>
<property name="inome" column="nome"></property>
<property name="cognome"></property>
<property name="ruolo"></property>
</join>
</class>
</hibernate-mapping>
but I got an error, saying that the number of fields for the key must be the same...
If I join only two table the mapping works:
<hibernate-mapping>
<class name="it.studio.model.AllProgModel" table="Allocazione">
<id name="aid" column="id"></id>
<property name="cf"></property>
<join table="Progetto" inverse="true">
<key column="id"></key>
<property name="nome"></property>
<property name="capo"></property>
<property name="descrizione"></property>
</join>
</class>
</hibernate-mapping>
'cause I declare only the desired field as key.
But in the first case, I need a key for table A and another for table B, and I cannot declare two <id>.
|