I am using service in CUBA-FRAMEWORK to do some data manipulation and getting the following error:
ClassCastException: java.util.Date cannot be cast to com.company.gms.entity.ProductionPlanResource
the error is originated in the following line of code:
matReqDate = DateUtils.addDays((Date)planQuery.getFirstResult().getStartDate(), daysOffset);
}
additional codes around :
Date reqShipDate = soline.getRequiredShipDate();
Date matReqDate;
TypedQuery<ProductionPlanResource> planQuery = persistence.getEntityManager()
.createQuery("select MIN(e.startDate) from mydb$ProductionPlanResource e " +
" where e.productionPlan.salesOrder.id = ?1 AND e.article.id = ?2", ProductionPlanResource.class);
planQuery.setParameter(1, soline.getSalesOrder().getId()).setParameter(2, article.getId());
if (planQuery.getResultList().size() > 0) {
matReqDate = DateUtils.addDays((Date)planQuery.getFirstResult().getStartDate(), daysOffset);
}
I tried this, but didn't help
java.sql.Date startDate = (java.sql.Date)planQuery.getFirstResult().getStartDate();
Thanks for helping.