Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366096

Summary: isNegated() returning wrong results
Product: z_Archived Reporter: Stephen DiMilla <stephen.dimilla>
Component: EclipselinkAssignee: Tom Ware <tom.ware>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: lance.andersen, stephen.dimilla, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
proposed fix
none
updated patch none

Description Stephen DiMilla CLA 2011-12-08 14:38:19 EST
Build Identifier: eclipselink-2.3.0.v20110604-r9504

Execute the following client code:

        CriteriaBuilder qbuilder = em.getCriteriaBuilder();

        System.out.println("Testing default");
        Boolean result = qbuilder.equal(qbuilder.literal("1"), "1").isNegated();
        if (!result) {
            System.out.println("Received expected result:" + result);
        } else {
            System.out.println("Expected:false , actual:" + result);
        }

        System.out.println("Testing when Predicate.not is present");
        result = qbuilder.equal(qbuilder.literal("1"), "1").not().isNegated();
        if (result) {
            System.out.println("Received expected result:" + result);
        } else {
            System.out.println("Expected:true, actual:" + result);
        }

        System.out.println("Testing when CriteriaBuilder.not is present");
        result = qbuilder.not(qbuilder.equal(qbuilder.literal("1"), "1")).isNegated();
        if (result) {
            System.out.println("Received expected result:" + result);
        } else {
            System.out.println("Expected:true, actual:" + result);
        }

The output is:

Testing default
Received expected result:false
Testing when Predicate.not is present
Expected:true, actual:false
Testing when CriteriaBuilder.not is present
Expected:true, actual:false


The second and third scenarios fail to return the correct result

Reproducible: Always
Comment 1 Tom Ware CLA 2012-04-05 11:01:24 EDT
Updating target milestone.
Comment 2 Stephen DiMilla CLA 2012-06-13 11:12:48 EDT
This failure is also seen with CriteriaBuilder.In.isNegated()
Comment 3 Tom Ware CLA 2013-02-06 11:49:28 EST
Created attachment 226645 [details]
proposed fix
Comment 4 Tom Ware CLA 2013-02-06 15:17:17 EST
Created attachment 226660 [details]
updated patch
Comment 5 Tom Ware CLA 2013-02-06 15:44:38 EST
Fix checked in - store isNegated in a variable and return that variable from the isNegatedCall

Reviewed by Gordon Yorke

Added test to JPA 2.1 Query test suite

Tested with JPA LRG
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:10:10 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink