About CriteriaBuilder


quot(x, y)

Create an expression that returns the quotient of its arguments.(Method of javax.persistence.criteria.CriteriaBuilder)


notLike(x, pattern)

Create a predicate for testing whether the expression does not satisfy the given pattern.(Method of javax.persistence.criteria.CriteriaBuilder)



Return an instance of CriteriaBuilder for the creation of CriteriaQuery objects.(Method of javax.persistence.EntityManagerFactory)


Criteria Query results in a NoResultException instead of returning object

When I run the following code    ... When I run the following code  CriteriaBuilder builder = em. getCriteriaBuilder ( ) ... of the CriteriaQuery and JPQL snippets: CriteriaBuilder builder = em. getCriteriaBuilder ( ) ...


Strange Error with Criteria API and Sorting

We're creating a simple selection (distinct) including an order clause. When watching the created criteria in debugger we get the correct expression: SELECT DISTINCT $1 FROM MyEntity $1 WHERE ((TYPE($1)=class test.MyEntity)) ORDER BY UPPER($1.name) DESC You can see that in the order by there's correctly a "$1" var. Running this (without the type thing before) in the explorer correctly returns the sorted results. However, running this with the criteria API produces this error: ... ; import javax. persistence . criteria . CriteriaBuilder ; import javax. persistence . criteria . ... ) . commit ( ) ;   CriteriaBuilder cb = em. getCriteriaBuilder ( ) ; ...


TYPE Expression

Hi there! Trying to add a simple type expression with the criteria api like in your sample: cb.notEqual(e.type(), cb.literal(Country.class)); results in the error: Caused by: com.objectdb.o.UserException: Attempt to store an instance of a non persistable type java.lang.Class at com.objectdb.o.MSG.d(MSG.java:61) at com.objectdb.o.TYW.writeElement(TYW.java:223) at com.objectdb.o.QRR.l(QRR.java:424) at com.objectdb.o.QRR.g(QRR.java:230) at com.objectdb.o.QRR.b(QRR.java:151) ... createEntityManager ( ) ; CriteriaBuilder cb = em. getCriteriaBuilder ( ) ; ... Root<T> from, CriteriaQuery< ? > query, CriteriaBuilder builder ) { query. where ( ...


JPA does not seem to be db agnostic

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). ... ( String username ) { CriteriaBuilder criteriaBuilder = em. getCriteriaBuilder ( ) ; ...


Criteria query error: Unexpected query token

Using JPA2, I can save entities now in JBoss, and also fetch them uniquely by id. However, if I try to fetch it by getting back all instances (e.g. findAll, I get the following error:   ... Class<T> aClass ) { CriteriaBuilder qb = entityManager. getCriteriaBuilder ( ... aClass) {      CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); ...


Searching lists within objects

Hi everyone,  I've a problem with searching on lists. I'm uncertain as to what the best form is, so I've created a maven project with all the classes and a unit test showing my issue. Pretty much I want to search using cb.isMember passing an object. This however does NOT work. I'm uncertain how the database is doing its matching, but it looks to me like it matches using objectids, which means you can only match isMember if you have a database object. This does not help as I'm never going to have the real object at search time. ... this is not satisfactory.  CriteriaBuilder cb = em. getCriteriaBuilder ( ) ; ...


Will ObjectDB support JPA 2.1 CriteriaDelete?

Code like this: CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); CriteriaDelete<AlertEntity> criteriaDelete = cb.createCriteriaDelete(entityClass); Throws: java.lang.UnsupportedOperationException at com.objectdb.jpa.criteria.CriteriaBuilderImpl.createCriteriaDelete(CriteriaBuilderImpl.java:1508) ... Code like this: CriteriaBuilder cb = getEntityManager ( ) . ...