Grails
  1. Grails
  2. GRAILS-4089

Default Sort Order for associations causes java.sql.SQLException: Column not found

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: 1.1-RC1
    • Fix Version/s: 2.0-M2
    • Component/s: Persistence
    • Labels:
      None

      Description

      Given the following domain objects:

      class Parent {
          static hasMany = [ childs : Child ]
          static mapping = {
             childs sort:"s"
          }
      }
      
      class Child {
          static belongsTo = [Parent]
          String s
      }
      

      If I try to fetch Parents that have been created previously (through the bootstrap) or try to create (and then show) a Parent through the scaffolding, I get the following error:

      <snipped>
      Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: Parent.childs#2
      at C_dev_projects_testApp_testApp_grails_app_views_parent_show_gsp.run(C_dev_projects_testApp_testApp_grails_app_views_parent_show_gsp:37)
      Caused by: java.sql.SQLException: Column not found: CHILDS0_.S in statement [select childs0_.parent_childs_id as parent1_0_, childs0_.child_id as child2_0_ from parent_child childs0_ where childs0_.parent_childs_id=? order by childs0_.s]
      at org.hsqldb.jdbc.Util.throwError(Unknown Source)
      at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
      at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
      at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:185)
      at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:278)
      ... 1 more

      It seems to be trying to sort by the relation table (parent_child), where the 's' column does not exist, instead of the child table.

        Activity

        Chris Brookes created issue -
        Graeme Rocher made changes -
        Field Original Value New Value
        Fix Version/s 1.1 [ 14930 ]
        Priority Minor [ 4 ] Critical [ 2 ]
        Hide
        Graeme Rocher added a comment -

        Seems to effect unidirectional associations

        Show
        Graeme Rocher added a comment - Seems to effect unidirectional associations
        Graeme Rocher made changes -
        Fix Version/s 1.1-RC2 [ 14930 ]
        Fix Version/s 1.1 [ 15043 ]
        Graeme Rocher made changes -
        Fix Version/s 1.2 [ 14155 ]
        Fix Version/s 1.1 [ 15043 ]
        Graeme Rocher made changes -
        Fix Version/s 1.2-M2 [ 15425 ]
        Fix Version/s 1.2-M1 [ 14155 ]
        Graeme Rocher made changes -
        Fix Version/s 1.2-M2 [ 15425 ]
        Fix Version/s 1.2-M3 [ 15547 ]
        Graeme Rocher made changes -
        Fix Version/s 1.2-M3 [ 15547 ]
        Graeme Rocher made changes -
        Fix Version/s 1.2-RC1 [ 15959 ]
        Priority Critical [ 2 ] Blocker [ 1 ]
        Graeme Rocher made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Graeme Rocher added a comment -

        Not supported in Hibernate core either it seems: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4394

        Show
        Graeme Rocher added a comment - Not supported in Hibernate core either it seems: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4394
        Graeme Rocher 12/Nov/2009 8:58 AM PST
        View full commit
        test for GRAILS-4089 "Default Sort Order for associations causes java.sql.SQLException: Column not found" marked currently as not yet implemented
        Graeme Rocher made changes -
        Status In Progress [ 3 ] Open [ 1 ]
        Hide
        Graeme Rocher added a comment -

        lowering priority, it seems as if this is a Hibernate core problem there are multiple open JIRAs related to the subject. It may be fixed in Hibernate 4.

        Show
        Graeme Rocher added a comment - lowering priority, it seems as if this is a Hibernate core problem there are multiple open JIRAs related to the subject. It may be fixed in Hibernate 4.
        Graeme Rocher made changes -
        Priority Blocker [ 1 ] Critical [ 2 ]
        Jeff Brown 01/Dec/2009 10:05 PM PST
        View full commit
        GRAILS-4089 - log a warning message when sorting by a child property on a unidirectional one to many relationship.
        Hide
        Graeme Rocher added a comment -

        There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3

        for 1.2 final only issues considered blocking will now be fixed

        Show
        Graeme Rocher added a comment - There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3 for 1.2 final only issues considered blocking will now be fixed
        Graeme Rocher made changes -
        Fix Version/s 1.2-RC1 [ 15959 ]
        Fix Version/s 1.3 [ 15400 ]
        Graeme Rocher made changes -
        Fix Version/s 1.3-M1 [ 15400 ]
        Fix Version/s 1.3-RC1 [ 16274 ]
        Graeme Rocher made changes -
        Fix Version/s 1.3-RC1 [ 16274 ]
        Graeme Rocher made changes -
        Assignee Graeme Rocher [ graemerocher ]
        Hide
        Graeme Rocher added a comment -

        Burt - could you take a look at this one.

        Show
        Graeme Rocher added a comment - Burt - could you take a look at this one.
        Graeme Rocher made changes -
        Assignee Burt Beckwith [ burtbeckwith ]
        Hide
        daniel added a comment -

        Are there any updates on this issue? Can anyone help? Work-arounds?

        Show
        daniel added a comment - Are there any updates on this issue? Can anyone help? Work-arounds?
        Contegix Support made changes -
        Project Import Thu Mar 24 21:22:24 CDT 2011 [ 1301019744151 ]
        Hide
        Fabien Benichou added a comment -

        The same for me ? No updates on this?

        Show
        Fabien Benichou added a comment - The same for me ? No updates on this?
        Burt Beckwith made changes -
        Workflow jira [ 35593 ] Grails [ 40009 ]
        Hide
        Burt Beckwith added a comment -

        One workaround is to make it bidirectional with "static belongsTo = [parent: Parent]". This removes the join table, and also gives you cascaded deletes.

        Show
        Burt Beckwith added a comment - One workaround is to make it bidirectional with "static belongsTo = [parent: Parent] ". This removes the join table, and also gives you cascaded deletes.
        Burt Beckwith made changes -
        Workflow Grails [ 40009 ] Copy of Grails [ 47443 ]
        Burt Beckwith made changes -
        Workflow Copy of Grails [ 47443 ] Grails [ 54853 ]
        Burt Beckwith made changes -
        Workflow Grails [ 54853 ] Grails2 [ 62405 ]
        Graeme Rocher made changes -
        Assignee Burt Beckwith [ burtbeckwith ] Graeme Rocher [ graemerocher ]
        Graeme Rocher made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Graeme Rocher 25/Aug/2011 8:46 AM PDT
        Hide
        Graeme Rocher added a comment -

        I'm closing this as won't fix since it isn't supported by hibernate which is what we rely on. I have added a better fail-fast error message stating we don't support default sort order for unidirectional associations to make it clear to the user

        Show
        Graeme Rocher added a comment - I'm closing this as won't fix since it isn't supported by hibernate which is what we rely on. I have added a better fail-fast error message stating we don't support default sort order for unidirectional associations to make it clear to the user
        Graeme Rocher made changes -
        Resolution Won't Fix [ 2 ]
        Status In Progress [ 3 ] Closed [ 6 ]
        Fix Version/s 2.0-M2 [ 12805 ]
        Burt Beckwith made changes -
        Workflow Grails2 [ 62405 ] jira [ 77026 ]
        Burt Beckwith made changes -
        Workflow jira [ 77026 ] Grails2 [ 79722 ]
        Peter Ledbrook made changes -
        Workflow Grails2 [ 79722 ] jira [ 88609 ]
        Peter Ledbrook made changes -
        Workflow jira [ 88609 ] Grails2 [ 96922 ]
        Hide
        Atsawin Chaowanakritsanakul added a comment -

        This bug was fixed in Hibernate 4.1.5. http://hibernate.atlassian.net/browse/HHH-4394
        Now, it could be fixed in Grails. Please reopen this issue.

        Show
        Atsawin Chaowanakritsanakul added a comment - This bug was fixed in Hibernate 4.1.5. http://hibernate.atlassian.net/browse/HHH-4394 Now, it could be fixed in Grails. Please reopen this issue.
        Hide
        Vincent Stoessel added a comment -

        Seeing this in 2.2.3, would love to have this working in grails

        Show
        Vincent Stoessel added a comment - Seeing this in 2.2.3, would love to have this working in grails

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Chris Brookes
          • Votes:
            37 Vote for this issue
            Watchers:
            37 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development