Hi,
I have problems sorting a criteria.
Code:
CriteriaBuilder builder = getEntityManager().getCriteriaBuilder();
CriteriaQuery<Object[]> criteria = builder.createQuery(Object[].class);
Root<GloCompany> gloCompanyRoot = criteria.from(GloCompany.class);
Join<GloCompany,GloCompanyAddress> gloCompanyAddresses = gloCompanyRoot.join(GloCompany_.gloCompanyAddresses, JoinType.LEFT);
Join<GloCompanyAddress,GloCompanyAddressLocale> gloCompanyAddressLocales = gloCompanyAddresses.join("gloCompanyAddressLocales", JoinType.LEFT);
criteria.orderBy(builder.asc(gloCompanyRoot.get("gloCompanyAddresses.gloCompanyAddressLocales.name")));
I get the following error on line:
criteria.orderBy(builder.asc(gloCompanyRoot.get("gloCompanyAddresses.gloCompanyAddressLocales.name")));Code:
java.lang.NullPointerException
at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:110)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:218)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:189)
at ....
I know i can do:
criteria.orderBy(builder.asc(gloCompanyAddressLocales .get("name")));
This will work.
I'm looking for a function to order a path given as string. (worked in hibernate criteria)
Thanks in advance,
Pieter Pareit