Home » Support » Forum » JPA does not seem to be db agnostic

JPA does not seem to be db agnostic

#1

The following jpa code works with mysql but not with objectdb. Why would this happen? The provider the both jpas is the same: EclipseLink. The link for the one used with mysql is org.eclipse.persistence.jpa.PersistenceProvider; the one for objectdb is com.objectdb.jpa.Provider (per the tutorials).

    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();
    }
#2

A valid JPQL query must include SELECT, otherwise the query is incomplete.

Some JPA implementations extend the standard JPQL by supporting queries with no SELECT.

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

Post Reply

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