glassfish
  1. glassfish
  2. GLASSFISH-20479

JPA 2.1: select where mystr<>'' also returns zero-length strings

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 4.0_b87_RC3
    • Fix Version/s: 4.0_b88_RC4
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      JDK 1.7.0_21, Glassfish 4.0_b88 (2013-05-05), JavaDB or MySQL

      Description

      Creating a JPA query searching for strings that are not empty - example:

      select e from NewEntity e where e.name<>''

      This also returns the empty strings where e.name = '' which is incorrect. This does not happen with earlier JPA/Eclipselink versions.

      I can provide a test case if necessary.

        Activity

        Hide
        Peter Salomonsen added a comment -

        Simple test case:

        EntityManager em = Persistence.createEntityManagerFactory("JPA21testPU").createEntityManager();
        em.getTransaction().begin();
        NewEntity ent = new NewEntity();
        ent.setName("Test");
        em.persist(ent);
        ent = new NewEntity();
        ent.setName("");
        em.persist(ent);
        em.getTransaction().commit();
        List<NewEntity> neList = em.createQuery("select e from NewEntity e where e.name<>''").getResultList();
        if(neList.size()!=1)

        { System.out.println("BUG: Should only return one entity - but returned: "+neList.size()); }

        for(NewEntity ne : neList)

        { System.out.println(ne.toString()+" name = '"+ne.getName()+"'"); }

        em.close();

        Show
        Peter Salomonsen added a comment - Simple test case: EntityManager em = Persistence.createEntityManagerFactory("JPA21testPU").createEntityManager(); em.getTransaction().begin(); NewEntity ent = new NewEntity(); ent.setName("Test"); em.persist(ent); ent = new NewEntity(); ent.setName(""); em.persist(ent); em.getTransaction().commit(); List<NewEntity> neList = em.createQuery("select e from NewEntity e where e.name<>''").getResultList(); if(neList.size()!=1) { System.out.println("BUG: Should only return one entity - but returned: "+neList.size()); } for(NewEntity ne : neList) { System.out.println(ne.toString()+" name = '"+ne.getName()+"'"); } em.close();
        Hide
        Mitesh Meswani added a comment -

        Fixed with integration of EclipseLink 2.5.0-RC2

        Show
        Mitesh Meswani added a comment - Fixed with integration of EclipseLink 2.5.0-RC2

          People

          • Assignee:
            Mitesh Meswani
            Reporter:
            Peter Salomonsen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: