Wednesday 15 May 2013

hibernate - Grails createCriteria returning null criteria -


I am receiving a strange NullPointerException in grails 2.1.1.

  Hibernate CriteriaBuilder crit = FattoriIndicator.createCriteria () crit.createAlias ​​("Indicator", "Ind") ... // NPE here, because the underlying criteria is zero   
  • The class is listed in hibernation
  • The other class is just right from the same working config file
  • The class has not been recently added, this is a For a long time

    Certainly something is missing, but I can not see it.

    EDIT: I'm sure that this code is configured correctly because this code works:

      Hibernate Criteria builder aa = FattoriIndicatori .createcriteria () Number res = crit.get {estimates {count ()}}    

    The problem is That some methods work only on HibernateCriteriaBuilder when it gets , close to list ), etc.

      Hibernate CriteriaBilder aa = FattoriIndicatori.createCriteria () Diff result = crit.list {createAlias ​​("Indicator", "Ind") eq ('ind.something', 'value') }   

    will work fine list method some initialization (underlying criteria example, which initially would be null ), Then closes the call to make the criteria, specification, then executes the resulting query and returns the result.

No comments:

Post a Comment