Search This Blog

Loading...

Thursday, February 21, 2008

transient,persistent or detached

After going through the life cycle, the question that comes into mind is that, how does hibernate know whether an object is transient,persistent or detached ?

A range of options are available for that. Hibernate will assume that an instance is unsaved
Transient instance if :
a) The identifier property is null
b) The version property (if exists) is null.
c) You supply an unsaved-value attribute in and the value of the identifier property
matches.
d) You supply Hibernate Interceptor and return Boolean.TRUE from Interceptor.isUnsaved()
after checking the instance in your code.

No comments: