I want to persist this:
The class Elemento persist fine with this mapping:
Code:
<hibernate-mapping>
<class name="especialista.regra.elemento.Elemento" table="ELEMENTOS" polymorphism="implicit">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property
name="nome"
column="ELEMENTO_NOME"/>
<property
name="confianca"
column="ELEMENTO_CONFIANCA"/>
<many-to-one name="valor"
class="especialista.regra.elemento.valor.Valor"
column="VALOR"
cascade="all"/>
<joined-subclass name="especialista.regra.elemento.Expressao"
table="ELEMENTO_EXPRESSOES">
<key column="id"/>
<property name="operacao" column="OPERACAO_EXPRESSAO"/>
<many-to-one name="elementoA"
class="especialista.regra.elemento.Elemento"
column="ELEMENTOA"
cascade="all"/>
<many-to-one name="elementoB"
class="especialista.regra.elemento.Elemento"
column="ELEMENTOB"
cascade="all"/>
</joined-subclass>
<joined-subclass name="especialista.regra.elemento.Constante"
table="ELEMENTO_CONSTANTES">
<key column="id"/>
</joined-subclass>
<joined-subclass name="especialista.regra.elemento.Variavel"
table="ELEMENTO_VARIAVEIS">
<key column="id"/>
</joined-subclass>
</class>
</hibernate-mapping>
The problem is with the class Clausula. When i try to persist this with one-to-one relation:
Code:
<one-to-one name="a" class="especialista.regra.elemento.Elemento" cascade="all"/>
<one-to-one name="b" class="especialista.regra.elemento.Elemento" cascade="all"/>
The values of a and b came confused.
For example:
If the value of a is 1 and value of b is 2
When i persist and try to read this. The values change to 1 both.
When i use many-to-one the value stay ok but the class instance is changed to EnhancerByCGLIB.
I need the real class name instance for one part of the Clausula code:
Code:
if (a instanceof Constante) ...
Anyone can help me please?
Thanks
HeatCold