aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate update in single transcation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate update in single transcation" Watch "hibernate update in single transcation" New topic
Author

hibernate update in single transcation

mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
i have problem when i retrieve data from honey table i have no problem in retrieving data.when i try to save a new value with the same honey instance i get the following error.but this how i must do only with the same instance not with new instance if honey class.Can anybody help me out in this..




thanks
mano
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Updating an identifier is an invalid thing to do. Suprisingly enough, the identifier identifies the object itself, so an update is really an insert. This is why Hibernate will not let you update the id of an object. Call save rather than update and you should be OK.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
Thanks for your reply , but it didn't work..

this is my code

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Can we see your mapping? You load your Honey object by an Integer id, but the exception message suggest firstName is your identifier. Which is odd.
mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
This is my real implementation code which i use in my project.

mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
this my mapping xml.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What does your dao persist method do?

Are you sure what you've posted is what you are deploying? The error message doesn't tie up which what you've got above.
[ December 21, 2007: Message edited by: Paul Sturrock ]
mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
this is my error message and the dao ,which has hibernate generated methods..

 
 
subject: hibernate update in single transcation
 
Similar Threads
update doesnt work in 1 transaction!
sesion.flush();
Error while updating in hibernate..
Update in hibernate
identifier of an instance modifier error. HELP!?