IntelliJ IDEA 2019.2 Help

Dynamic Finders

Grails integration allows performing dynamic queries for the domain class instances. 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 Pet.groovy there are four fields:

    String name Date birthDate PetType type Owner owner

  2. In a Grails view, controller, or test class, create a method. For example, in the PetSpec.groovy, create method testSomething().

  3. In the method body, reference a domain class to be queried, and start typing the query. Press N/A:

    Query completion

  4. Press N/A once more, and select the desired condition from the suggestion list:

    Smart query completion

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

Last modified: 19 August 2019

See Also

Procedures:

Reference: