IntelliJ IDEA 13.1 Web Help

Some features described here are available in Ultimate edition only.

Grails integration allows performing dynamic queries for the domain class instances. So doing, code completion makes it possible to combine different queries based on the fields of the domain classes.

To create a dynamic query
  1. In a Grails domain class, declare fields to define mappings. For example, in the domain class Book.groovy there are four fields:
    Date acquired
    String title
    String author1
    String author2
                
  2. In a Grails view, controller, or test class, create a method. For example, in the BookTests.groovy, create method testSomething().
  3. In the method body, reference a domain class to be queried, and start typing the query. Press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space:

    grailsDynQuery1.png

  4. Press Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceControl SpaceControl SpaceControl Space once more, and select the desired condition from the suggestion list:

    grailsDynQuery2.png

    Repeat code completion to concatenate as many search conditions as required.

    Tip

    The same procedure applies to the count function:

    grailsDynQuery3.png

See Also

Procedures:

Reference:

External Links:

Web Resources: