Hi all, i'm new to hibernate and i have to admit that i have a little bit of overhead.... but i will try to explain the best i can:
i need to map a table like this:
+------------+---------+------------+-------------+------------+--------------+-------------+
| ID_AZIENDA | WHO_INS | DATA_INS | DATA_INIZIO | DATA_FINE | ID_PERSONALE | ID_COMMESSA |
+------------+---------+------------+-------------+------------+--------------+-------------+
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 2 | 1 |
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 2 | 2 |
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 2 | 3 |
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 3 | 1 |
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 3 | 2 |
| 1 | 1_1 | null | 2004-01-01 | 2007-12-31 | 3 | 3 |
+------------+---------+------------+-------------+------------+--------------+-------------+
where the key is (ID_AZIENDA, ID_PERSONALE, ID_COMMESSA)
so i was trying to do something like this:
Quote:
<hibernate-mapping>
<class name="objectFactory.Pers_comm" table="pers_comm">
<composite-id>
<key-many-to-one name="azienda" class="objectFactory.Azienda" column="id_azienda"/>
<key-many-to-one name="personale" class="objectFactory.Personale" column="id_personale"/>
<key-property name="commesse"/>
</composite-id>
<set name="commesse" table="commessa">
<many-to-one name="commmessa" column="ID_COMMESSA" class="objectFactory.Commessa"/>
</set>
<property
name="who_ins"
type="string">
<column
name="who_ins"
length="30"
/>
</property>
<property
name="data_ins"
type="date">
<column
name="data_ins"
/>
</property>
<property
name="data_inizio"
type="date">
<column
name="data_inizio"
/>
</property>
<property
name="data_fine"
type="date">
<column
name="data_fine"
/>
</property>
</class>
well ... for know i have also xml parse errors.... but those this make sense?
i mean how can i define the key for the set collection?
this is the java class i would like to use:
Quote:
package objectFactory;
import java.sql.Date;
import java.util.*;
public class Pers_comm implements java.io.Serializable
{
private Azienda azienda;
private String who_ins;
private Date data_ins;
private Date data_inizio;
private Date data_fine;
private Personale personale;
private Set commessa;
public void setAzienda(Azienda a)
{
azienda = a;
}
public Azienda getAzienda()
{
return azienda;
}
public void setWho_ins(String w)
{
who_ins = w;
}
public String getWho_ins()
{
return who_ins;
}
public void setData_ins(Date d)
{
data_ins = d;
}
public Date getData_ins()
{
return data_ins;
}
public void setData_inizio(Date d)
{
data_inizio = d;
}
public Date getData_inizio()
{
return data_inizio;
}
public void setData_fine(Date d)
{
data_fine = d;
}
public Date getData_fine()
{
return data_fine;
}
public void setPersonale(Personale p)
{
personale = p;
}
public Personale getPersonale()
{
return personale;
}
public Set getCommessa() {
return commessa;
}
public void setCommessa(Set commessa) {
this.commessa = commessa;
}
}