When I use JPA with MySQL, the below query works fine. But when I use it with ObjectDB, it throws the exception below.
public Friendship getFriendship(String username) {
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Friendship> query = criteriaBuilder.createQuery(Friendship.class);
Root<Friendship> root = query.from(Friendship.class);
Path<String> path = root.<String>get("username");
query.where(criteriaBuilder.equal(path, username));
return em.createQuery(query).getSingleResult();
}
The error from the browser
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: com.objectdb.o._PersistenceException: Unexpected query token 'FROM' (SELECT is expected)
root cause
com.objectdb.o._PersistenceException: Unexpected query token 'FROM' (SELECT is expected)
root cause
com.objectdb.o.UserException: Unexpected query token 'FROM' (SELECT is expected)