Possible issue for JPQL IS EMPTY expression


Possible issue for JPQL IS EMPTY comparison expression:

SELECT e FROM MyEntity e WHERE e.collection-valued IS EMPTY

throws javax.persistence.PersistenceException:
Invalid operand type  for operator IS EMPTY (error 756)


Note: It doesn' t work with SIZE():

SELECT e FROM MyEntity e WHERE SIZE(e.collection-valued)=0



Please follow the posting instructions and provide test cases for your questions / issues.

This time you may base your test on the following example, in which IS EMPTY works well:

import java.util.*;

import javax.persistence.*;
import javax.persistence.Query;

public class T759 {

    public static void main(String [] args){
        EntityManagerFactory emf =
        EntityManager em = emf.createEntityManager();

        em.persist(new MyEntity());
        Query query = em.createQuery(
            "SELECT e FROM MyEntity e WHERE e.list IS EMPTY");


    public static class MyEntity {
        List<MyEntity> list = new ArrayList<MyEntity>();
ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

It is little bit more complicated for a collection-valued relationship bidirectional and not a field:

class MyEntity {
    ArrayList<OtherEntity> others = new ArrayList<OtherEntity>();
    void addOtherEntity(OtherEntity other) {

class OtherEntity { 
    MyEntity myentity;        



You are right. Unfortunately collection operators are currently not supported for mapped by (inverse) collections.

Please see more details and a possible workaround in this new issue.

Hopefully this will be solved soon.

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

Post Reply

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