Friday, August 9, 2013

Grails: how to set data binding to use get method instead of load one?

Grails: how to set data binding to use get method instead of load one?

If i have a form such as bellow
<input type="text" name="someCollection[0].someAssociation.id"/>
<input type="text" name="someCollection[1].someAssociation.id"/>
<input type="text" name="someCollection[2].someAssociation.id"/>
Because Grails provides automatic data binding when it encounters a .id
suffix, it seems Grails uses get method instead of load one which implies
3 queries as follows
SELECT * FROM SomeAssociationClass WHERE id = ?
SELECT * FROM SomeAssociationClass WHERE id = ?
SELECT * FROM SomeAssociationClass WHERE id = ?
I just need load method because it does not hit the database unless you
use other than getId() (NOT APPLIED). So, how can i customize data binding
so that it uses load method ?

No comments:

Post a Comment