Does hibernate provide a method that returns an object's state (transient, persistent, detached)?
see Javadoc Hibernate Session and check the methods
i would use 'get' and furthermore check for changed values, after that its just an "saveOrUpdate" to persist or update (and re-attach) the actual object
Session.contains tells you if an object is associated with the session. If it has no identifier, it's transient, if it has an identifier and associated with the session, persistent. Identifier but not associated with a session, detached.
If that doesn't help, consider rephrasing your question with more context, that is, why do you need to know the state of an object in the first place?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With