-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problems with cascade
PostPosted: Mon Jun 07, 2004 12:27 pm 
Newbie

Joined: Thu Jun 03, 2004 7:08 pm
Posts: 6
The problem is when i have repeated columns, so that i have to put insert="false" and update="false" in the many-to-one association.
When i save an object , the associated many-to-one object is not saved. At least i don't find it on the database.

For example:

Code:
       <composite-id>
                     <key-property
                        name="assetCode"
                        type="java.lang.String"
                        column="cod_valor"
                />

                     <key-property
                        name="company"
                        type="java.lang.String"
                        column="cod_empresa"
                />

        </composite-id>

         <many-to-one
            name="assetDesc"
            class="classxxxx"
            cascade="all"
            outer-join="auto"
            update="false"
            insert="false"
            access="property"
        >
            <column
                name="cod_valor"
            />
            <column
                name="cod_empresa"
            />
        </many-to-one>


Well . hope some solution exists. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use key-many-to-one


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 1:29 pm 
Newbie

Joined: Thu Jun 03, 2004 7:08 pm
Posts: 6
Yeah, i tried that. And works fine.

Now, the problem remains when multiple many-to-one relationships share columns. In this case key-many-to-one doesn't allow to share columns and it doesn't have the attributes update and insert to set the "false".

NOTE: the database schema can't be changed

Example:

Code:
<composite-id
            name="pkReal"
            class="net.technisys.bancoval.credival.domain.service.portfolio.guarantee.asset.AssetGuaranteePrimaryKey"
        >
                     <key-property
                        name="assetCode"
                        type="java.lang.String"
                        column="cod_valor"
                />

                     <key-property
                        name="company"
                        type="java.lang.String"
                        column="cod_empresa"
                />

                     <key-property
                        name="personIntCode"
                        type="java.lang.String"
                        column="cod_int_persona"
                />

                     <key-property
                        name="portfolioCode"
                        type="java.lang.String"
                        column="cod_cartera"
                />

        </composite-id>

<many-to-one
            name="portfolioGuarantee"
            class="net.technisys.bancoval.credival.domain.service.portfolio.guarantee.PortfolioGuaranteeBusiness"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            access="property"
        >
            <column
                name="cod_empresa"
            />
            <column
                name="cod_cartera"
            />
        </many-to-one>
       
        <many-to-one
            name="personGuarantee"
            class="net.technisys.bancoval.credival.domain.service.portfolio.guarantee.asset.person.PersonGuaranteeBusiness"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            access="property"
        >
            <column
                name="cod_empresa"
            />
            <column
                name="cod_int_persona"
            />
            <column
                name="cod_cartera"
            />
        </many-to-one>
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 1:33 pm 
Newbie

Joined: Thu Jun 03, 2004 7:08 pm
Posts: 6
In the example above cascade is set to "none", but i also tried "all" and didn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is quite resonable to enable cascade on a many-to-one with insert="false" update="false".


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 2:40 pm 
Newbie

Joined: Thu Jun 03, 2004 7:08 pm
Posts: 6
Yes, i suposse.

But i don't know if the problem i have is clear.

I want to have multiple many-to-one that share columns. Also i want those columns to be part of the primary key.

I haven't found how to tell hibernate to insert data in the tables associated by the many-to-one relationships. (Because i'm forced to use update="false" insert="false" and i cant use key-many-to-one).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.