While using CriteriaQuery with cartesian product of two entities like shown below, if package name of the Entity classes Foo and Bar begin with SQL Keywords, {{QuerySyntaxException: unexpected token:}} is raised.
{{CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Object[]> query = criteriaBuilder.createQuery(Object[].class); Root<Foo> root = query.from(Foo.class); Root<Bar> mappingRoot = query.from(Bar.class);
query.multiselect(root, criteriaBuilder.count(mappingRoot.get(Bar_.id))) .where(criteriaBuilder.notEqual(root.get(Bar_.property), "someValue")); hiby().createQuery(query).getResultList(); }}
Same issue arrises if HQL is used with cartesian product or with one or multiple joins.
E.g. if fully classified name of Foo and Bar is in.company.module.Foo and in.company.module.Bar, the exception is raised at "in".company.module.Bar for {{QuerySyntaxException: unexpected token: in}}. |
|