Home » Support » Forum » "Unexpected query expression" using CriteriaQuery FetchParent Interface

"Unexpected query expression" using CriteriaQuery FetchParent Interface

#1

Using the fetch over Root attribute, the exception is:

com.objectdb.o._PersistenceException: Unexpected query expression end (non keyword identifier is expected)] with root cause
com.objectdb.o.UserException: Unexpected query expression end (non keyword identifier is expected)
at com.objectdb.o.MSG.d(MSG.java:62) ... ...
#2

Please demonstrate the error with a test case.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3
public class App {
public static void main(String[] args) {
  EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestesPU");
  EntityManager em = emf.createEntityManager();

  CriteriaBuilder cb = em.getCriteriaBuilder();
  CriteriaQuery<Person> criteriaQuery = cb.createQuery(Person.class);
  Root<Person> root = criteriaQuery.from(Person.class);
  root.fetch("PersonData"); //@OneToOne relationship
  criteriaQuery.select(root);

  System.out.println(em.createQuery(criteriaQuery).getResultList());

}

}

 

Exception in thread "main" [ObjectDB 2.5.6_05] javax.persistence.PersistenceException
Unexpected query expression end (non keyword identifier is expected) (error 751)
(position 9) at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:725)
#4

Thank you for this bug report. Please try version 2.5.7 that should fix this issue.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

Congratulations!
It's working perfectly in this new version 2.5.7!
Thanks UK!


Post Reply

To post a reply and/or subscribe to update notifications - please login