Hibernate uses the unsaved-value to detect if your object has been inserted yet or not. If the id of the object matches the unsaved value, it does an insert, otherwise an update. (There are lots of ways to modify this behavior.)
see
http://www.hibernate.org/hib_docs/refer ... aration-id, where it says "(4) unsaved-value (optional - defaults to null): An identifier property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from transient instances that were saved or loaded in a previous session. "