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

Bug 345849

Summary: Query by Example Object doesn't obey Wrapping Policy
Product: z_Archived Reporter: Jeff Domeyer <domeyerj>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P3 CC: eclipselink.orm-inbox, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
proposed-patch none

Description Jeff Domeyer CLA 2011-05-15 11:27:52 EDT
Build Identifier: 2.2.0

When using a ReadAllQuery created by setting the example object, the QueryByExampleMechanism just compares the query class to the example object's class (line 77), without checking to see if the object is wrapped via a wrapping policy.

In my application, I've set a wrapping policy for all objects coming out of the db, and if I use them without unwrapping them myself as an example in the query, the criteria building will fail and just return all results without criteria. The easy solution for me is to just unwrap it myself, but it seems like it would be easy to check for that scenario.

Reproducible: Always

Steps to Reproduce:
1. Customize your session by setting a wrapper policy.
2. Create a wrapped object and pass it in as an example object for the queryByExample.
Comment 1 Jeff Domeyer CLA 2011-05-16 15:02:39 EDT
Created attachment 195781 [details]
proposed-patch
Comment 2 Jeff Domeyer CLA 2011-05-18 17:03:16 EDT
Comment on attachment 195781 [details]
proposed-patch

proposed-patch is garbage, doesn't fix the problem.
Comment 3 Jeff Domeyer CLA 2011-05-19 08:21:10 EDT
Turns out it was a combination of using proxies as wrappers and the values being retrieved from the proxy instead of the wrapped object. At the time of creating a query, there isn't a session from which to reference. So you can't figure out that there will be a wrapper policy later on.

I think it will muddy the waters too much to try to bake something in that will retrieve a different referenceClass due to a wrapper policy after a session is executing the query. So it's probably best to just unwrap the object on our own before using the query by example functionality.
Comment 4 Tom Ware CLA 2011-05-31 09:41:57 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Tom Ware CLA 2011-06-02 10:37:24 EDT
Investigating
Comment 6 Tom Ware CLA 2011-06-02 10:39:17 EDT
Just reread bug.  Unassigning.  Sorry for confusion
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:20:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink