Grails
GORM Gotchas
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.
It covers:
- Save ( Validation & Hibernate Session).
- Updates (Dirty Checking)
- Relations (one-to-one, one-to-many, many-to-many)
- Lazy Loading
A must read.
You Know SQL. You Know Queries. Here's GORM.
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!
How and When to use various GORM Querying options
@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()
- SQL
Using Hibernate Native SQL Queries
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.
Grails - Using Groovy SQL
@mrhaki shows how to execute custom SQL with Groovy SQL. Step one create a new instance of groovy.sql.Sql. Want to get fancy? Learn how to create a Spring bean for Groovy SQL.
Note: you don't need to call close as pointed by @albertovilches
Logging from none Grails Artifacts - Use an AST
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.
Comment
Grails 3.2 has been released. GORM 6 has been released. ππΌπ
I ought to do a GORM edition. That it is exactly what this issue is. GORM.
Sergio del Amo