Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » left side of the IN operator missing?
left side of the IN operator missing? [message #377457] Mon, 04 August 2008 14:20 Go to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
I have a JPQL query that looks like this:
select sol from Sellorderline sol where sol.iArticle in (select a from License l inner join l.iLicenseArticlesWhereIAmLicense la inner join la.iArticle a where l = :license)

It tries to find Sellorderlines where the article that is sold is present in the specified license. The generated SQL looks like this (I've stripped some of the returned fields):
SELECT t1.sellorderlinenr, t1.articlenr, ...,t1.dwhby FROM article t0, sellorderline t1 WHERE ( IN (SELECT DISTINCT t2.articlenr, t2.articletypenr, t2.description, t2.sellingprice, t2.length, t2.width, t2.inserted, t2.std_reservation, t2.haslicenses, t2.minimalstock, t2.is_landscape, t2.actueel, t2.weight, t2.c, t2.f, t2.info, t2.rolinstellingenok, t2.rolkop, t2.tapper, t2.veer, t2.lazylock, t2.managestock, t2.seqnr, t2.keywords, t2.opweb, t2.dwhmodified, t2.dwhby, t2.ean, t2.opwebdate, t2.salestatus FROM license t4, license_article t3, article t2 WHERE ((? = t4.licensenr) AND ((t3.licensenr = t4.licensenr) AND (t2.articlenr = t3.articlenr)))) AND (t0.articlenr = t1.articlenr))

Note the "WHERE ( IN (SELECT"; the left side of the IN is not present! Am I doing something wrong?

Tom
Re: left side of the IN operator missing? [message #377459 is a reply to message #377457] Mon, 04 August 2008 14:40 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
> I have a JPQL query that looks like this:
> select sol from Sellorderline sol where sol.iArticle in (select a from
> License l inner join l.iLicenseArticlesWhereIAmLicense la inner join
> la.iArticle a where l = :license)

I solved it myself: you cannot do a entity-in-entity, you need to do attribute-in-attribute. The huge list of fields that the subquery returned was the clue.

not:
.... and sol.iArticle in (select a ...

but:
.... and sol.iArticle.iArticlenr in (select a.iArticlenr ...

Maybe an error message or something would be appropriate?

Tom
Re: left side of the IN operator missing? [message #378595 is a reply to message #377459] Tue, 05 August 2008 13:41 Go to previous messageGo to next message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Feel free to log an enhancement request. Instead of an error message, I
think it would be nice if it just worked, the IN sub-select could just
select the Id.

-- James
Re: left side of the IN operator missing? [message #378599 is a reply to message #378595] Tue, 05 August 2008 14:46 Go to previous message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
> Feel free to log an enhancement request. Instead of an error message, I
> think it would be nice if it just worked, the IN sub-select could just
> select the Id.

True. On the other hand, that won't work with composite keys, so it is not a 100% solution.
Previous Topic:unidirectional one-to-many mapping with join column
Next Topic:Change tracking of many-to-many relationship broken?
Goto Forum:
  


Current Time: Tue Sep 16 01:05:49 GMT 2014

Powered by FUDForum. Page generated in 0.01577 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software