-->
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.  [ 2 posts ] 
Author Message
 Post subject: problem while calling 'session.update()' !!!
PostPosted: Fri Aug 12, 2005 1:20 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:postgresql 8.0[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]

Hi all,

I'm actually having a problem when calling session.update method. Here is a description of my problem. I have a class 'Customer' and my corresponding table 'customer' in my database in which i have a row with id=1 and name='test'. I then do the following to update the row with id=1:

Customer c = new Customer(1, "test1");
session.update(c);

I got an exception, ClassNotfoundException NotUniqueObjectFound as soon as I call session.update(c). But the strange thing is that at times the update is done correctly. Why I got the exception?

In fact to update an object I found that I should get an instance of the object first by calling session.get(ClassName, UniqueIdentifier) not by doing a newInstance(). Why?


Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 1:38 am 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
You have a transient object. Session.update() is intended for detached objects. Call Session.saveOrUpdate() instead.


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