title: grails hibernate query not working inside integration test
body: <p>I have the following domain class:</p>
  
  <pre><code>package gcbgb
  
  class Score {
      Double victoryPoints
  
      static belongsTo = [ player:Player, gameTable:GameTable ]
  
      static constraints = {
          victoryPoints nullable:true
      }
  }
  </code></pre>
  
  <p>which represents the number of <code>victoryPoints</code> a particular <code>Player</code> received while playing a game at a particular <code>GameTable</code>.</p>
  
  <p>I also have a service:</p>
  
  <pre><code>package gcbgb
  
  import grails.transaction.Transactional
  
  @Transactional class RoundService {
  
      int tableRank(Score score) {
          return Score.findAll("from Score as s where s.gameTable = ? and s.victoryPoints &gt;= ?", [score.gameTable, score.victoryPoints]).size()
      }
  
  }
  </code></pre>
  
  <p>Which helps decide each <code>Player's</code> rank at a given <code>GameTable</code> based on the number of <code>victoryPoints</code> she earned compared to the other <code>Players</code>.</p>
  
  <p>Naturally, I've also got an integration test of this function:</p>
  
  <pre><code>package gcbgb
  
  
  import grails.test.mixin.integration.Integration
  import grails.test.mixin.TestFor
  import grails.transaction.*
  import spock.lang.*
  
  @Integration
  @Rollback
  @TestFor(RoundService)
  class RoundServiceSpec extends Specification {
  
      def setup() {
      }
  
      def cleanup() {
      }
  
      void "test tableRank"() {
          def player6 = new Player(name:"Player6").save(failOnError:true)
          def player5 = new Player(name:"Player5").save(failOnError:true)
          def player4 = new Player(name:"Player4").save(failOnError:true)
          def player3 = new Player(name:"Player3").save(failOnError:true)
          def player2 = new Player(name:"Player2").save(failOnError:true)
          def player1 = new Player(name:"Player1").save(failOnError:true)
  
          Round round1 = new Round(number:1, duration:"1.5").save(failOnError:true)
          GameTable gameTable1 = new GameTable(gameName:"Game1")
          round1.addToGameTables(gameTable1)
          round1.save(failOnError:true)
  
          Score score1 = Score.link(gameTable1, player1).setVictoryPoints(4).save(failOnError:true)
          Score score2 = Score.link(gameTable1, player2).setVictoryPoints(3).save(failOnError:true)
          Score score3 = Score.link(gameTable1, player3).setVictoryPoints(3).save(failOnError:true)
          Score score4 = Score.link(gameTable1, player4).setVictoryPoints(2).save(failOnError:true)
          Score score5 = Score.link(gameTable1, player5).setVictoryPoints(1).save(failOnError:true)
  
          expect:
              1 == service.tableRank(score1)
              3 == service.tableRank(score2)
              3 == service.tableRank(score3)
              4 == service.tableRank(score4)
              5 == service.tableRank(score5)
      }
  }
  </code></pre>
  
  <p>However, when I run this test I get the following failure:</p>
  
  <pre><code>&lt;testcase name="test tableRank" classname="gcbgb.RoundServiceSpec" time="8.329"&gt;&lt;failure message="org.hibernate.QueryException: could not resolve property: victoryPoints of: gcbgb.Score" type="org.hibernate.QueryException"&gt;org.hibernate.QueryException: could not resolve property: victoryPoints of: gcbgb.Score
      at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:62)
      at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:56)
      at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1831)
      at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:46)
      at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1806)
      at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:510)
      at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:525)
      at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:66)
      at org.hibernate.criterion.Junction.toSqlString(Junction.java:84)
      at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:400)
      at org.hibernate.loader.criteria.CriteriaJoinWalker.&lt;init&gt;(CriteriaJoinWalker.java:106)
      at org.hibernate.loader.criteria.CriteriaJoinWalker.&lt;init&gt;(CriteriaJoinWalker.java:75)
      at org.hibernate.loader.criteria.CriteriaLoader.&lt;init&gt;(CriteriaLoader.java:80)
      at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1773)
      at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363)
      at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.invokeMethod(AbstractHibernateCriteriaBuilder.java:1687)
      at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.list(AbstractHibernateCriteriaBuilder.java:1558)
      at gcbgb.RoundService.$tt__tableRank(RoundService.groovy:13)
      at gcbgb.RoundService.tableRank_closure2(RoundService.groovy)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:430)
      at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
      at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
      at gcbgb.RoundServiceSpec.$tt__$spock_feature_0_0(RoundServiceSpec.groovy:40)
      at gcbgb.RoundServiceSpec.test tableRank_closure3(RoundServiceSpec.groovy)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:430)
      at grails.transaction.GrailsTransactionTemplate$1.doInTransaction(GrailsTransactionTemplate.groovy:70)
      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
      at grails.transaction.GrailsTransactionTemplate.executeAndRollback(GrailsTransactionTemplate.groovy:67)
      at gcbgb.RoundServiceSpec.test tableRank(RoundServiceSpec.groovy)
  &lt;/failure&gt;&lt;/testcase&gt;
  </code></pre>
  
  <p>Which suggests that there is a problem with my <code>Score.victoryPoints</code> member.</p>