Mapeamento no Hibernate com foreign key

0 respostas
E

Como eu faco o mapeamento das classes com foreign key ?
Tenho essas classes:
public class PaisPK
private Integer cdPais;

public class Pais

private PaisPK paisPK;

private String nmPais;

private String sgPais;

private Integer cdMoeda;

private Integer flDefault;

private Estado estado;
public class EstadoPK

private Integer cdPais;

private Integer cdEstado;
public class Estado

private EstadoPK estadoPK;

private String nmEstado;

private String deUf;

private Integer flDefault;

private Pais pais;
public class MunicipioPK

private Integer cdPais;

private Integer cdEstado;

private Integer cdMunicipio;

public class Municipio

private MunicipioPK municipioPK;
private String nmMunicipio;
private Integer flDefault;
private Integer cdNre;
private Integer cdTipomunicipio;
private Integer cdMunicipioibge;
private Integer cdDigitoibge;
private Estado estado;

Mapeamento

<hibernate-mapping>

<class name=“br.com.aff.Municipio” table=“ESFFMUNICIPIO”>

<composite-id name=“municipioPK” class=“br.com.softplan.aff.MunicipioPK”>

<key-property name=“cdPais” type=“int”/>

<key-property name=“cdEstado” type=“int”/>

<key-property name=“cdMunicipio” type=“int”/>

</composite-id>

<property name=“nmMunicipio” type=“string”/>

<property name=“flDefault” type=“int”/>

<property name=“cdNre” type=“int”/>

<property name=“cdTipomunicipio” type=“int”/>

<property name=“cdMunicipioibge” type=“int”/>

<property name=“cdDigitoibge” type=“int”/>

<many-to-one
name="estado"
column="cdEstado"
insert="false"
update="false"
outer-join=“true” />

Criado 20 de junho de 2005
Respostas 0
Participantes 1