Grails
  1. Grails
  2. GRAILS-5887

GORM querying for collections of basic non-domain types

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None

      Description

      Since a few versions ago, Grails has supported that a domain class has a collection of basic non-domain types
      The GORM will create a related table as per http://jira.codehaus.org/browse/GRAILS-1023

      For ex:
      class MyDomain
      {
      static hasMany=[names:String]
      }

      Grails will create:

      • a "my_domain" table for the main domain class
      • a "my_domain_names" table with
      • a "my_domain_id" foreign key pointing to "my_domain"
      • a "names_string" column with the actual string

      The GORM will provide the normal MyDomain.addToNames("...") methods, but WILL NOT provide dynamic methods to query MyDomain for certain names.
      Also, there's no way with the criteria builders to do something like:
      MyDomain.createCriteria {
      names

      { ... // it complains that names is not an association!!! }

      }

      The only way to query for MyDomain's that have a certain name is, according to someone on the list, to use HQL:

      def results = MyDomain.executeQuery('from MyDomain where :name in elements(names)', [name: "something"])

      I think that collection of non-domain types should behave the same as domain associations with respect to persistence and querying.

        Issue Links

          Activity

          Show
          Jeff Scott Brown added a comment - This may be blocked by http://opensource.atlassian.com/projects/hibernate/browse/HHH-869
          Hide
          Jeff Scott Brown added a comment -
          Show
          Jeff Scott Brown added a comment - The current link may be https://hibernate.atlassian.net/browse/HHH-869

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              BarzilaiSpinak
            • Votes:
              16 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:
                Last Reviewed:

                Development