Over a million developers have joined DZone.

Easy Grails with IntelliJ IDEA - 2. Chaining Queries

DZone's Guide to

Easy Grails with IntelliJ IDEA - 2. Chaining Queries

· ·
Free Resource

As promised in the previous post, let’s continue with Grails support in  IntelliJ IDEA 8. Today we’ll see how the powerful IntelliJ IDEA‘s code completion applies to the Grails applications.

Suppose you have a Grails application, where you create a domain class, using the New context menu command:






Declare some fields that will be mapped to a datasource:









Next, use the scaffolding to create, for example, a test class, and start typing a query:












This is where code completion comes to help. Press Ctrl+Space. The suggestion list shows all the fields declared in your domain class. Let’s select the findByName option:













After that, press Ctrl+Space once more – now the suggestion list shows combined queries:
















With each invocation of code completion, IntelliJ IDEA suggests the appropriate combined queries. Thus, you can go through all the fields of your domain class, and easily create queries of any level of complexity.



Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}