当我将 JPA 与 MySQL 一起使用时,以下查询可以正常工作。但是当我将它与 ObjectDB 一起使用时,它会抛出下面的异常。
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();
}
来自浏览器的错误
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)