Hi everyone,
I am trying to map a sequence, a surrogate key, to my sub-class. I have tried the attribute 'generated' but but is did not work.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="br.com.sapiensit.sigterra.administrativo.model.bo" default-lazy="false">
<class name="ObjetoImobiliarioBO" table="TB_OBJETO_IMOBILIARIO">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">SQ_OBJETO_IMOBILIARIO</param>
</generator>
</id>
<property name="classe" column="TP_CLASSE_IMOBILIARIA"/>
<property name="tipo" column="TP_OBJETO_IMOBILIARIO" not-null="true"/>
<!-- mapeamento da subclasse ObjetoEspecialBO -->
<joined-subclass name="ObjetoEspecialBO" table="TB_OBJETO_ESPECIAL">
<key column="ID_OBJETO_IMOBILIARIO" />
<property name="id" column="ID" not-null="true" generated="insert"/>
<property name="descricao" column="DS_OBJETO_ESPECIAL" not-null="true"/>
</joined-subclass>
</class>
</hibernate-mapping>
The tables are:
TB_OBJETO_IMOBILIARIO
ID NOT NULL NUMBER(*,0)
TP_CLASSE_IMOBILIARIA NUMBER(*,0)
TP_OBJETO_IMOBILIARIO NOT NULL NUMBER(*,0)
and
TB_OBJETO_ESPECIAL
ID NOT NULL NUMBER(*,0)
DS_OBJETO_ESPECIAL NOT NULL VARCHAR2(100)
ID_OBJETO_IMOBILIARIO NOT NULL NUMBER(*,0)
How do I map my id in the joined-subclass (objetoEspecialBO) so it can be generated by a sequence (SQ_OBJETO_ESPECIAL) of the database?
Can anybody give me a hint?
Thanks, Guilherme
|