• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update in hibernate

 
Betsy Camel
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting the following exception when i try to update a record.


org.hibernate.HibernateException: identifier of an instance of Honey altered from 10 to 0
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:82)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at grtr.main(grtr.java:56)



the code which i using to update is as follows


Honey message =(Honey) session.load( Honey.class, new Integer(10) );
message.setFirstname("Greetings Earthling");
session.update(message);
tx.commit();
session.close();


Any help will be very much appreciated .
Thanks
betsy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic