Простой - если объект с таким же идентификатором существует в БД, он обновляет его, если идентификатор (первичный ключ) равен нулю, то сохраняет его как новое значение - следовательно, saveOrUpdate - в зависимости от того, существует ли это значение вDB или новое значение.
Сопоставление идентификатора происходит путем сопоставления вашего идентификатора pojo в hbm под тегом с указанным столбцом.
saveOrUpdate () выполняет следующие действия:
if the object is already persistent in this session, do nothing
if another object associated with the session has the same identifier, throw an exception
if the object has no identifier property, save() it
if the object's identifier has the value assigned to a newly instantiated object, save() it
if the object is versioned by a <version> or <timestamp>, and the version property value is the same value assigned to a newly instantiated object, save() it
otherwise update() the object
С здесь
Надеюсь, это поможет.