Tuesday, March 29, 2011

Multi-Associative GORM Criteria with Projections

I have three domain classes: Lead, Submission and BuyerLog:

I have a need to get the number of duplicate leads which share the same leadBuyer (in the BuyerLog domain class). Here is the SQL:

I want to do this using GORM / Criteria Builder. Here's my final code:

Thanks to schmolly159 on the #grails freenode IRC channel for the examples and continued help.