EclipseLink JPA on Oracle WebLogic 12c with a JAX-RS based JSF and JQuery thin client
Enable JPA Metamodel Modelgen compilation in your Eclipse project
Turn on APT in your project settings and add EclipseLink jars
An automatic rebuild will show the new _ underscore JPA canonical metamodel classes that can be used for typesafe Criteria API queries.
Parsing JSON via AJAX call from JQuery client
JAX-RS backend server
@Path("/read") public class RestServiceImpl extends Application { // not supported until 2.0 https://java.net/jira/browse/JERSEY-517 //@EJB(name="ejb/ApplicationService") // not for JAX-RS //@Inject private ApplicationServiceLocal applicationServiceLocal; @GET @Path("/json/latest/{id}") //@Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) public ListgetLatestJSON(@PathParam("id")String identifier) { return getApplicationService().latest(identifier); } .... @Stateless(mappedName = "applicationService") public class ApplicationService implements ApplicationServiceLocal { @PersistenceContext(unitName="gps", type=PersistenceContextType.TRANSACTION) private EntityManager entityManager; public List latest(String user) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery query = cb.createQuery(Record.class); Root target = query.from(Record.class); SingularAttribute anAttribute = entityManager.getMetamodel() .entity(Record.class).getSingularAttribute("tsStop", Long.class); query.orderBy(cb.desc(target.get(anAttribute))); query.where( cb.equal(target.get("userId"), user)); TypedQuery typedQuery = entityManager.createQuery(query); typedQuery.setMaxResults(1); Record result = (Record)typedQuery.getSingleResult(); List list = new ArrayList<>(); list.add(result); return list; } ...