This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have a Person Class.to tht i'm setting some vales which gets saved in my database through hibernate. then i used Criteria to load those values.it did perfectly fine. then i gave person.setId(5) which was 4 earlier and then session.saveOrUpdate(person) it's giving me error as org.hibernate.HibernateException: identifier of an instance of Person was altered from 4 to 5
Updating an object and changing the id is not really a valid thing to do in relational databases. The id uniquely identifies a record, if you change it it is analagous to deleting a record and inserting a new one. So, Hibernate will complain if you try to do this.
dynamic-update: If true, then when Hibernate updates a row in the database for a class attribute that has changed, it generates an UPDATE SQL statement at runtime during the update() method call on the session and only include the columns of the table that have been updated. This is an optional attribute; the default is false.