Returns whether the domain instance is attached to a currently active session or not. This method is often used on conjunction with the merge or attach methods.


Book b =
if(!b.isAttached()) {


Grails uses Hibernate which manages each persistent object in a persistence session. A new session is created per request and is closed at the end of the request. If an object is read from the session and placed into a web scope such as the HttpSession it is seen as detached, since the persistence session has been closed. You can use the attach method to re-attach an existing persistent instance to the persistence session of the current request.