[GLASSFISH-20479] JPA 2.1: select where mystr<>'' also returns zero-length strings Created: 06/May/13  Updated: 09/May/13  Resolved: 09/May/13

Status: Resolved
Project: glassfish
Component/s: entity-persistence
Affects Version/s: 4.0_b87_RC3
Fix Version/s: 4.0_b88_RC4

Type: Bug Priority: Critical
Reporter: Peter Salomonsen Assignee: Mitesh Meswani
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

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


Tags: glassfish4, jpa, persistence

 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.



 Comments   
Comment by Peter Salomonsen [ 07/May/13 ]

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();

Comment by Mitesh Meswani [ 09/May/13 ]

Fixed with integration of EclipseLink 2.5.0-RC2

Generated at Sat Dec 03 22:36:39 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.