-->
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.  [ 1 post ] 
Author Message
 Post subject: One To One Save or Update
PostPosted: Tue Jun 22, 2004 7:15 pm 
Newbie

Joined: Tue Jun 22, 2004 7:00 pm
Posts: 1
I have two classes related by an one-to-one relationship using the following code:

Code:
<class  name="PessoaTO" table="pessoa">
  <id
      name="id"
      type="java.lang.Long"
      column="id"
>
     <generator class="native"/>
</id>
    <version column="timestamp" name="timestamp"  type="java.sql.Timestamp" />
<one-to-one name="codConjuge" constrained="false" outer-join="false" class="com.sib.transobject.pessoa.ConjugeTO" />



Code:
    <class name="ConjugeTO" table="conjuge">
   <id
   name="id"
   type="java.lang.Long"
   column="id"
    >
     <generator class="foreign">
                <param name="property">codPessoa</param>
       </generator>
   </id>
   <one-to-one name="codPessoa" constrained="true" outer-join="auto" class="com.sib.transobject.pessoa.PessoaTO"/>


To save or update a line in the conjuge table i'm doing this:

Code:
PessoaTO pessoaTO = (PessoaTO)DAOFactory.getPessoa().load(new Long(32));
pessoaTO.setCodConjuge(conjugeTO);
conjugeTO.setCodPessoa(pessoaTO);   
ConjugeBO conjugeBO = new ConjugeBO();      
conjugeBO.saveOrUpdate(conjugeTO);


When there isn't a line in Conjuge table with id=32 it works fine. The line is created with the same id as the person. When i try to load a Conjuge it works as well. But when this line ( Conjuge with field id 32 ) already exists in the database insted of updating the conjuge table with the new values i'm getting a
NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 32

Anybody know how to make this work?


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

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.