Pessoal,
acredito que seja algo símples, porém não consegui achar no fórum nenhum exemplo.
Como eu faço o mapeamento onde o campo no Modelo é um Objeto e no Banco é apenas uma foreign key ???
Agradeço qualquer ajuda !!!
Segue o exemplo abaixo:
Modelo:
public class Grupo implements Serializable
{
private static final long serialVersionUID = 1L;
private int id;
private Destino dest;
private Funcionario func;
// Construtor, Gets, Sets...
}
Mapeamento:
<hibernate-mapping>
<class name="modelo.Grupo" table="grupo">
<id name="id" column="id" type="integer">
<generator class="sequence">
<param name="sequence">grupo_id_seq</param>
</generator>
</id>
<property name="dest" column="id_destino" type="string"/> //Type ????????
<property name="func" column="id_func" type="string"/> //Type ????????
</class>
</hibernate-mapping>
Tabela grupo:
CREATE TABLE grupo
(
id_func character varying(10) NOT NULL,
id_destino character varying(15) NOT NULL,
id serial NOT NULL,
CONSTRAINT grupo_pk PRIMARY KEY (id),
CONSTRAINT grupo_destino_fk FOREIGN KEY (id_destino)
REFERENCES destino (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT grupo_func_fk FOREIGN KEY (id_func)
REFERENCES funcionario (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)