-->
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.  [ 5 posts ] 
Author Message
 Post subject: Error Saving a Object relationship with other - Part II
PostPosted: Thu Aug 12, 2004 11:46 am 
Newbie

Joined: Wed Aug 11, 2004 11:12 am
Posts: 10
Location: Brazil
Hi There,

I


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 12:17 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
When you call save in the second session, then it tries to save (which depends on your cascade property) the cidades instance again but it should only update the cidades. So try saveOrUpdate and not save.

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 12:58 pm 
Newbie

Joined: Wed Aug 11, 2004 11:12 am
Posts: 10
Location: Brazil
Reto wrote:
When you call save in the second session, then it tries to save (which depends on your cascade property) the cidades instance again but it should only update the cidades. So try saveOrUpdate and not save.

Reto


Hi Reto

I already tried saveOrUpdate method, but doesn't work too, show the same exception


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 4:17 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
Can you show me the full mapping for your classes and the relationship?

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 8:27 am 
Newbie

Joined: Wed Aug 11, 2004 11:12 am
Posts: 10
Location: Brazil
Reto wrote:
Can you show me the full mapping for your classes and the relationship?

Reto


Sure, below follow the full mapping file.
Cidades class (not relationship)
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 1.1//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
    <class
        name="br.com.junior.models.Cidades"
        table="cidades"
    >

        <id
            name="codigo"
            column="codigo"
            type="java.lang.Integer"
        >
            <generator class="assigned">
            </generator>
        </id>

        <property
            name="nome"
            type="java.lang.String"
            column="nome"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Cidades.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Clientes here have the many-to-one relationship
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 1.1//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd">

<hibernate-mapping>
    <class
        name="br.com.junior.models.Cidades"
        table="cidades"
    >

        <id
            name="codigo"
            column="codigo"
            type="java.lang.Integer"
        >
            <generator class="assigned">
            </generator>
        </id>

        <property
            name="nome"
            type="java.lang.String"
            column="nome"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Cidades.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Talking with a friend, he said that is not a good idea to use 2 differents session. We need to avoid to use 2 Session (maybe performance). I'll try to change my architecture


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