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).
@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.
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!