Grails
  1. Grails
  2. GRAILS-7829

Criteria only works with LTE in tests but LE in running code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-M1
    • Fix Version/s: 2.0-M2
    • Component/s: Testing
    • Labels:

      Description

      I have to following method:

      def criteria = JournalEntry.createCriteria();
      criteria.list {
        and {
          le("validFrom", new Date())
          ge("validTo", new Date())
        }
        order("name")
      }
      

      If I test this piece of code I get the next error message

      groovy.lang.MissingMethodException: No signature of method: grails.gorm.CriteriaBuilder.le() is applicable for argument types: (java.lang.String, java.util.Date) values: [validFrom, Wed Aug 03 09:35:32 CEST 2011]
      Possible solutions: lt(java.lang.String, java.lang.Object), lte(java.lang.String, java.lang.Object), ne(java.lang.String, java.lang.Object), id(), eq(java.lang.String, java.lang.Object), gt(java.lang.String, java.lang.Object)

      So I changed the code to use lte and gte
      Now when I run the application (run-app) I get the 'slightly' different error message

      groovy.lang.MissingMethodException: No signature of method: grails.orm.HibernateCriteriaBuilder.lte() is applicable for argument types: (java.lang.String, java.util.Date) values: [validFrom, Wed Aug 03 09:46:41 CEST 2011]
      Possible solutions: le(java.lang.String, java.lang.Object), lt(java.lang.String, java.lang.Object), ge(java.lang.String, java.lang.Object), gt(java.lang.String, java.lang.Object), like(java.lang.String, java.lang.Object), ne(java.lang.String, java.lang.Object)

      I'm a bit confused here what should I be using and who is right, my unit tests or my running application?

        Activity

        Hide
        Stefan Kohler added a comment -

        Added the error message from my running application, I noticed that it's slightly different. Seems that my tests are using grails.gorm.CriteriaBuilder where the application is using grails.orm.HibernateCriteriaBuilder and those don't share the same footprint

        Show
        Stefan Kohler added a comment - Added the error message from my running application, I noticed that it's slightly different. Seems that my tests are using grails.gorm.CriteriaBuilder where the application is using grails.orm.HibernateCriteriaBuilder and those don't share the same footprint
        Show
        Graeme Rocher added a comment - fixed by https://github.com/SpringSource/grails-data-mapping/commit/47996e7cebc41161c0979708b137f7177237ccf8

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Stefan Kohler
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development