Code:
save
Serializable save(Object object)
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update"
Parameters:
object - a transient instance of a persistent class
Returns:
the generated identifier
In layman if your generator class is native/sequence/etc then its hibernate job to save the entity in database with a valid key.
Once it save in database it returns the primary key /id that it used earlier.
In case generator class is assigned it will return the same key /id provided you..
Hope its clear now