Note that there are some explanatory texts on larger screens.

plurals
  1. POfindAllByPropertyInList results in wrong result, JOIN related or hibernate Distinct/paging problem?
    primarykey
    data
    text
    <p>I have some strange results of findAllByPropertyInList() and think this is a bug in grails. See [1], the result is not what I expect it to be and what other queries say. Could it be that some kind of JOIN blows up the result, than max-property is executed and afterwards DISTINCT decreases the number of results again?</p> <p>Or does this have to do with Hibernate not being able to use DISTINCT and pagination proerties in one query?</p> <p>thx Sebastian</p> <p>[1]</p> <pre><code>def criteria = Foo.createCriteria() def results = criteria.listDistinct() { ... } results.id.unique().size() ==&gt;34 results.topic.unique().size() // some of the topics are duplicate ==&gt;25 def more = Foo.findAll([max:20, offset:0]).size() ==&gt;20 def more = Foo.getAll(results.id).size() ==&gt;34 def more = Foo.findAllByTopicInList(results.topic, [max:20, offset:0]).size() ==&gt; 7 // expected 25 def more = Foo.findAllByIdInList(results.id, [max:20, offset:0]).size() ==&gt; 7 // expected 34 class Foo { String topic SubCategory subCategory List&lt;Article&gt; articles WritingStyle writingStyle SortedSet&lt;Keyword&gt; keywords = []as SortedSet SortedSet&lt;String&gt; linkTexts = []as SortedSet ArticleType articleType = ArticleType.FreestyleArticle static belongsTo = [project: Project] static hasMany = [articles:Article, keywords: Keyword, linkTexts: String] static constraints = { topic(blank: false, size: 1..200) subCategory(nullable: false) writingStyle(nullable: true) articles nullable:true } static mapping = { writingStyle fetch: 'join' subCategory fetch: 'join' keywords cascade: 'all-delete-orphan' keywords fetch: 'join' linkTexts cascade: 'all-delete-orphan' } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload