143 words

JPA does not seem to be db agnostic

#1
2012-10-03 16:18

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();
    }
kasavbere
kasavbere's picture
Joined on 2012-09-30
User Post #3
#2
2012-10-04 03:23

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)
support
support's picture
Joined on 2010-05-03
User Post #1,289

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel