Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts

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.

checking out grails

one week ago i started trying out grails and it`s really amazing how `convention over configuration` accelerates web development. a grails application consists of three (or four?) layers: a set of views and controllers (one for each domain model class), a service layer and a persistence layer which is integrated into the domain model (this is quite a new approach, i think).

the project starts creating an empty domain model class which actually grails creates for you from the command line. then you need to fill this class with its properties. grails can then create all other components (view, controller, persistence, tests, ...) for you either using scaffolding (i.e. components are generated at runtime) or by generating the according groovy files. the generated artefacts are created based on useful defaults (the basic crud actions are implemented) and can be customized by the developer later on.

all in all i`m very confident with what i`m able to do with grails after only one week. but i think what helped very much is that i`m a bit familiar with the frameworks used by grails (groovy/java, spring, spring mvc, hibernate). the next days will go on learning grails and have a deeper look into the details of the different layers.