I am testing hibernate and giving this query to
transaction = session.beginTransaction();
city = new City(\"A\");
city = (City)session.merge(city);
city.setNam
It's a sequencing issue. Actually not an issue. Hibernate is doing exactly what you told it to do. As @TejasArjun says, merge is about merging in deteched data. here's what is going on:
...
city = (City)session.merge(city);
// No different to save(). Hibernate schedules an insert to the
// database to store the current record.
city.setName("B");
// The object is now flagged as dirty and needing to be saved.
// Hiberate automatically tracks properties on objects and knows when they change.
transaction.commit();
// Hibernate sees that 'city' has been changed since it was saved,
// so it schedules an update to store the new data.