Friday, February 15, 2008

grails orm (gorm)

grails object relational mapping is so great. it`s based on hibernate and one of its coolest features is dynamic finders. a dynamic finder in grails is a method for querying data that does not exist up front but is created at runtime.

consider a domain model class user which has properties birthday and username. you can then query data calling User.findByUsername(uname) or User.findByUsernameLike(uname) or even User.findByUsernameAndBirthdayLessThan(uname, beforeDate) without implementing or even declaring these methods in any way - they are generated dynamically at runtime and this is mainly possible because of groovy`s dynamic features.

No comments: