JQPL on object extraction returns eclipselink.left-join-fetch is not valid

Hello,

It is potentially issue in the CUBA build or issue in the Part 5 lab steps https://www.cuba-platform.com/system/files/Final CUBA Hands on Labs (EN).pdf from Yury Artamonov

Basically, JQPL query “select o.mechanic, count(o.id) from workshop$Order o group by o.mechanic” against product configuration from page 10 of the above instruction results in the exception “JQPL on object extraction returns eclipselink.left-join-fetch is not valid”

Please recommend steps to resolve the issue (confirm the issue in CUBA or missed steps from the lab).

Java 1.8.0_65 / CUBA Studio 2.0.1

1 Like

Attaching full OrderServiceBean.java here:

/*

  • Copyright © 2015 workshop
    */
    package com.company.workshop.service;

import com.company.workshop.entity.Mechanic;
import com.company.workshop.entity.Order;
import com.company.workshop.entity.SparePart;
import com.haulmont.cuba.core.EntityManager;
import com.haulmont.cuba.core.Persistence;
import com.haulmont.cuba.core.Query;
import com.haulmont.cuba.core.global.View;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import java.math.BigDecimal;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**

  • @author vskryabin
    */
    @Service(OrderService.NAME)
    public class OrderServiceBean implements OrderService {

    @Inject
    private Persistence persistence;

    @Override
    @Transactional
    public Map<Mechanic, Long> getMechanicOrdersStats() {
    EntityManager em = persistence.getEntityManager();

     Query query = em.createQuery("select o.mechanic, count(o.id) from workshop$Order o group by o.mechanic");
     query.setView(Mechanic.class, View.MINIMAL);
    
     List<Object[]> resultList = query.getResultList();
    
     Map<Mechanic, Long> stats = new HashMap<>();
     for (Object[] o : resultList) {
         stats.put((Mechanic)o[0], (Long)o[1]);
     }
     return stats;
    

    }

    @Override
    public BigDecimal calculateAmount(Order order) {
    BigDecimal amount = new BigDecimal(0);
    if (order.getHoursSpent() != null) {
    amount = amount.add(new BigDecimal(order.getHoursSpent())
    .multiply(order.getMechanic().getHourlyRate()));
    }
    if (order.getParts() != null) {
    for (SparePart part : order.getParts()) {
    amount = amount.add(part.getPrice());
    }
    }
    if (LocalDate.now().getDayOfWeek() == DayOfWeek.WEDNESDAY) {
    amount = amount.multiply(new BigDecimal(0.9));
    }
    return amount;
    }

}

Attaching issue here, when opening Orders after this code is added:

IllegalArgumentException: Query select o.mechanic, count(o.id) from workshop$Order o group by o.mechanic, query hint eclipselink.left-join-fetch is not valid for this type of query.

I might have found the reason. I used Platform 6.0.2. And lab says - use 5.6.7. It is a known issue then for 6.0.2?

Hello Slava,
we will update and publish our hands on labs according to 6.0 CUBA version next week. For now Hands on Lab are adopted for version 5.6.7. Thank you for reporting this issue, looks like we need to fix something in 6.0.2.

Thank you !!! On 5.6.7 it works just fine.
BTW, one more issue for 6.0.2 - Edit Report => Parameters and Formats => Override Parameter Name (Like start date instead of CreateTs). Save. Go back. Parameter didn’t save no matter what way you try. On 5.6.7 it also works as expected.
Good luck!

Hi, we have published new full version of labs with CUBA 6.0.4. You can find it here.