Tuesday, February 1, 2011

What will do the persistent() and save() methods?

persistent() method is used to makes transient instance persistent. it does not guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. It will not execute the INSERT statement if it is called outside of the transanctions boundaries.
It violates the NOT NULL constraint upon a foreign key.


Save() method will return an identifier. If an INSERT has to be executed to get the identifier ( e.g. "identity" generator, not "sequence"), this INSERT happens immediately, no matter if you are inside or outside of a transaction.

It will not violate a NOT NULL constraint.

No comments:

Post a Comment