This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 259867 - Improve error message for: WHERE entity in (subquery)
Summary: Improve error message for: WHERE entity in (subquery)
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-02 10:44 EST by Gili Mising name CLA
Modified: 2022-06-09 10:30 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gili Mising name CLA 2009-01-02 10:44:02 EST
Build ID: n/a

Steps To Reproduce:
1. Issue a query containing "where entity in (subquery")
2. EclipseLink will translate this into an invalid SQL statement
3. The database will throw an obscure error


More information:
EclipseLink should detect the fact that it doesn't support "entity in (subquery)" and throw a clearer error message. It should suggest that developers use "entity.id in (subquery)" instead.
Comment 1 Andrei Ilitchev CLA 2009-01-02 11:02:47 EST
Here's the original message exchange.

Andrei Ilitchev wrote:
> 
> The spec. doesn't allow using entities directly with IN (see spec. 4.6.8
> and 
> 4.14), so instead of
> "select image from Image as image where image in (select imageToTag0.image 
> ...
> use something like:
> "select image from Image as image where image.id in (select 
> imageToTag0.image.id ...
> 
> ----- Original Message ----- 
> From: "cowwoc" <cowwoc@bbs.darktech.org>
> To: <eclipselink-users@eclipse.org>
> Sent: Wednesday, December 31, 2008 3:34 PM
> Subject: [eclipselink-users] EclipseLink converts query wrong
> 
> 
>>
>> Hi,
>>
>> I invoke EntityManager.createQuery("select image from Image as image
>> where
>> image in (select imageToTag0.image from ImageToTag as imageToTag0 where
>> imageToTag0.tag = :tag0) and image in (select imageToTag1.image from
>> ImageToTag as imageToTag1 where imageToTag1.tag = :tag1) order by
>> image.id");
>>
>> EclipseLink 1.0.2 converts this to:
>>
>> "t0.ID, t0.VERSION, t0.creationDate, t0.parentId, t0.ownerId, t0.dataId,
>> t0.contentTypeId, t0.specificationId, t0.overlayId FROM image t0 WHERE ( 
>> IN
>> (SELECT t1.ID, t1.VERSION, t1.creationDate, t1.parentId, t1.ownerId,
>> t1.dataId, t1.contentTypeId, t1.specificationId, t1.overlayId FROM
>> image_to_tag t2 LEFT OUTER JOIN image t1 ON (t1.ID = t2.IMAGE_ID) WHERE
>> (t2.TAG_ID = ?)) AND  IN (SELECT t3.ID, t3.VERSION, t3.creationDate,
>> t3.parentId, t3.ownerId, t3.dataId, t3.contentTypeId, t3.specificationId,
>> t3.overlayId FROM image_to_tag t4 LEFT OUTER JOIN image t3 ON (t3.ID =
>> t4.IMAGE_ID) WHERE (t4.TAG_ID = ?))) ORDER BY t0.ID ASC" under MySQL.
>>
>> Notice how it produces this malformed SQL: "WHERE ( IN". Any ideas?
>>
>> Gili
>> -- 
Comment 2 Tom Ware CLA 2009-01-07 11:13:11 EST
targetting for 1.1X since the bug list for 1.1 is finalized.  This will make it a candiate for the next patch release.
Comment 3 Peter Krogh CLA 2009-11-27 13:54:23 EST
 This bug is being moved to Future where we can properly sort them all together based on community votes and severity. We will then assign them accordingly to future patch sets and releases.
Comment 4 Peter Krogh CLA 2009-11-30 11:36:11 EST
Changing the priority of the bugs that have been recently triaged to future.  Targetting them to P2 will differentiate them from the P3s that have been triaged into future earlier.
Comment 5 James Sutherland CLA 2011-11-16 10:39:32 EST
Fixed this so it works.  object can now be used with in and sub-selects, or parameters.
Comment 6 James Sutherland CLA 2011-11-16 11:25:38 EST
See, Bug#314025
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:30:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink