-->
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: identifier of an instance of Contact altered from 1 to 3
PostPosted: Fri Feb 13, 2004 10:30 am 
Newbie

Joined: Wed Jan 14, 2004 5:10 am
Posts: 4
hello, i have the following problem :

i have a tree, that lists my DB to my gui.

there arte categorys and contacts for example.

once i click on a button "new" when a category is selected in the tree, i can enter values for a new contact.

a new contact object is created and an ID generated for it ( i use Integer id's i generate by a sequence table )

then i say session.save(myContactToSave) and all is fine, it works.

but when i click on an existing contact - lets say with an id 1 - it shows me the selected contact in my form, fine.

after that i click on a category and again do the "new" button and create a new contact object.

the id generated for this new contact is 3 and i say session.save (myContactToSave) but this time i get an exception, saying identifier of an instance of Contact altered from 1 to 3.

iam confused, why it dont works when there was a existing contact selected before ?
somehow hibernate thinks i want to save the former selected contact with a new ID and values, but it is a new one......

help !!

thx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 10:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Do you reuse some old object instance? You are not generating those ids yourself are you?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 10:45 am 
Newbie

Joined: Wed Jan 14, 2004 5:10 am
Posts: 4
i do. i generate em myself. and no, i dont use some old reference ( as far as i know from debugging lol )


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 10:48 am 
Newbie

Joined: Wed Jan 14, 2004 5:10 am
Posts: 4
public void saveContactOnly(Contact pContact, Category pCategory) {
log.debug("entering DB-Save................");

try {
mContact = pContact;
log.debug("kontakt der jetzt gespeichert wird = " + mContact);
mCategory = pCategory;

//setze CategoryID f


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2004 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Look at the Log. I really suspect you are reusing some old objects incidentially. You should also ponder if your session lifecycle is not to long ...


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.