Unwanted collection fetch in Hibernate with scrollable results

I am trying to use Hibernate to retrieve approximately 100 million rows from a table. I have a permanent object that contains a collection of fees inside (another permanent person). Given that I will sort out the result and get access to commission fees for each object, I want to readily charge a fee to avoid the problem with n + 1.

It should also be mentioned that I want to join it in another table called Provider (individual mapping, but without a foreign key). I tried:

String query = "select new " + Order.class.getName() 
           + "(i, p) from Item i left join fetch i.fees f, Provider p where "
           + "p.factoryId=i.factoryId and p.factoryRef=i.factoryRef";

return session.createQuery(query).scroll();

The My Order class contains the Provider field and the Item field. I get this error:

Called: org.hibernate.QueryException: The specified specified connection, but the owner of the resulting association was not present in the select list

Order, Item ( , ) .

+5
2

SelectClause :

if ( !fromElementsForLoad.contains( origin ) ) {
                        throw new QueryException(
                                "query specified join fetching, but the owner " +
                                "of the fetched association was not present in the select list " +
                                "[" + fromElement.getDisplayText() + "]"
                        );

, fetch, hibernate , , . fromElementsForLoad.contains( origin )

, , , , . , , .

, Item.class Order.class , , .

, . SelectClause.class , fromElementsForLoad.

n + 1, Order.class . .

, .

+1

left join fetch i.fees f .

0

All Articles