Wednesday, June 17, 2009

Grails : Create read only domain objects

When we use the get method, the object is loaded from the database in a modifiable state.
In other words, you can make changes to the object, which then get persisted to the database.
If you want to load an object in a read-only state, you can use the read method instead:

def album = Album.read(params.id)

In this case, the Album instance returned cannot be modified. Any changes you make to the
object will not be persisted.

Regards,
~~Amit Jain~~

No comments:

Post a Comment