-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Crazy Mapping Problem
PostPosted: Wed Nov 07, 2007 3:01 pm 
Newbie

Joined: Wed Nov 07, 2007 2:46 pm
Posts: 6
I want to persist this:

Image

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 08, 2007 8:37 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Hi the first problem you described is known and discribed, I just don't remember where :(
It appears when you have two references from one class to one other class.

The second one concerning the proxy. You could turn that off (check the docu for proxy). But this is generally not recommended since it would impact performance.

Why can't you use the proxy?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 08, 2007 8:57 am 
Newbie

Joined: Wed Nov 07, 2007 2:46 pm
Posts: 6
schauder wrote:
Hi the first problem you described is known and discribed, I just don't remember where :(
It appears when you have two references from one class to one other class.

The second one concerning the proxy. You could turn that off (check the docu for proxy). But this is generally not recommended since it would impact performance.

Why can't you use the proxy?


Thanks man! Using the lazy="false" the second case works fine!
The first case i ll study but thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.