Lets start with a classic must read for every GORM developer. GORM Gotchas Series; Part 1, Part 2, Part 3. A notorious collection of blog posts by @pledbrook.
- Save ( Validation & Hibernate Session).
- Updates (Dirty Checking)
- Relations (one-to-one, one-to-many, many-to-many)
- Lazy Loading
A must read.
Last issue we talked how to log the SQL being generated by GORM. In these slides, @tvinke compares the different querying options provided by GORM. He shows the SQL being generated by each one. His comparison focus in three axis (readability, writability and testability).
Diagram in Slide 56 is gorgeous. Clip it to Evernote!
@AlexTatiyants analyses GORM different query options:
- Dynamic finders
- Where queries (Complex filters, query associations, property comparison and subqueries)
- Criteria (fetch mode, projections)
- HQL - Find() and FindAll(), ExecuteQuery()
Sometimes we want to use Hibernate native SQL in our code. For example we might need to invoke a selectable stored procedure, we cannot invoke in another way.
Don't just query, learn different ways to transform the results from a query to other objects.
After last week recommendation, @sbglasius and @alvaro_sanchez pointed me to use an AST to log from none Grails artefacts. Reading about the topic I found this post by @asteingr with a more detailed explanation.
Pss : @Slf4j, more generic, should be the way to go. I updated my post.