Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345849 - Query by Example Object doesn't obey Wrapping Policy
Summary: Query by Example Object doesn't obey Wrapping Policy
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-15 11:27 EDT by Jeff Domeyer CLA
Modified: 2022-06-09 10:20 EDT (History)
2 users (show)

See Also:


Attachments
proposed-patch (1.96 KB, patch)
2011-05-16 15:02 EDT, Jeff Domeyer CLA
no flags Details | Diff

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