Здравствуйте, PAS_Tor, Вы писали:
PAS>Что-то интересное Вы описываете. На мой взгляд дело не в постраничном отображении. Хотя думаю меня поправят если что.
PAS>Судя по Вашему ответу, Вы смотрели логи Hibernate и видели формируемый SQL? Можете его выложить?
Похоже SQL не понадобится, вот кусок из hibernate tutorial (
здесь):
3.3. Removing duplicate objects
The following HQL can be used to retrieve books and their associated chapters where at least one of
the chapter titles includes the word “Hibernate”. The result contains pairs of a book and a chapter.
from Book book join book.chapters chapter
where chapter.title like '%Hibernate%'
For the implicit version of the above query, only the book objects will be included. But to our
surprise the book objects are duplicated. The time of duplication is equal to how many chapters
have “Hibernate” like title.
from Book book
where book.chapters.title like '%Hibernate%'
According to the explanation given by Hibernate, it is a normal behavior since Hibernate always
returns a list of the same size as the underlying JDBC ResultSet. We can use a LinkedHashSet to
filter the duplicate objects while keeping the order of original list.
Query query = session.createQuery(
"from Book book where book.chapters.title like '%Hibernate%'");
List books = query.list();
Set uniqueBooks = new LinkedHashSet(books);
Вообще, думаю, что проблему можно решить с помощью setFetchSize, но ещё не пробовал.