To use saveOrUpdate() function of hibernate you have to set attribute of your PK to "increment" in hbm.xml file related to your pojo.
when you try to use this function , note that not to set the primary key and either in editing mode just fetch it from db once.
the hibernate checks the value of PK and decides to insert or edit a record itself.
the key point is that u use the correct style for PK which is "increment" in this case.