Prevent Mass Assignment in Grails with Command Objects
Use Grails command objects as an allow-list for editable fields to prevent mass assignment and keep web input validation out of your domain model.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use Grails command objects as an allow-list for editable fields to prevent mass assignment and keep web input validation out of your domain model.
Decide between lazy, eager select, and eager join fetching for Grails GORM hasMany associations while avoiding N+1 queries, duplicates, and pagination errors.
Use Grails GORM dynamic finders for simple CRUD lookups, but switch to Criteria or HQL for joins, aggregations, and reports to avoid runtime errors and N+1 queries.
Compare dynamic finders, criteria API, and where queries in Grails GORM. Learn to avoid N+1, pick pagination strategies, and verify SQL with logging.
Grails services are transactional by default, but @Transactional can be too coarse. GORM's withTransaction gives you programmatic control for conditional commits, nested logic, and retry scenarios—if you understand its rollback rules and nesting quirks.
Learn how Grails GORM dynamic finders let you replace boilerplate HQL with concise, readable service methods while understanding their limits and refactoring risks.
This note outlines how to structure a Grails service layer using declarative transaction management, covering requirements, minimal design, trust boundaries, verification steps, failure modes, and when to adopt a more complex architecture.
Learn how to use Grails GORM’s type‑safe ‘where’ query DSL to build paginated, sorted, and projected queries. A concrete example with a Person domain shows how to avoid HQL pitfalls and keep your code refactor‑safe.
Dynamic finders let you query Grails domain classes with a concise method name. This article explains how they work, shows a working example, and lists limits and common pitfalls so you can use them safely and efficiently.