Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366096 - isNegated() returning wrong results
Summary: isNegated() returning wrong results
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Tom Ware CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-08 14:38 EST by Stephen DiMilla CLA
Modified: 2022-06-09 10:10 EDT (History)
3 users (show)

See Also:


Attachments
proposed fix (6.91 KB, patch)
2013-02-06 11:49 EST, Tom Ware CLA
no flags Details | Diff
updated patch (9.02 KB, patch)
2013-02-06 15:17 EST, Tom Ware CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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