You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Nikita Timofeev (JIRA)" <ji...@apache.org> on 2018/08/29 09:41:00 UTC
[jira] [Updated] (CAY-2468) Support subqueries in Expression API
[ https://issues.apache.org/jira/browse/CAY-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev updated CAY-2468:
---------------------------------
Description:
Currently there is no way to use subqueries in {{SelectQuery}} or {{ObjectSelect}}.
So we need a way to do so in {{Expression}} API.
Simple version can be implemented like this:
{code:java}
ObjectSelect<Painting> subquery = ObjectSelect.query(...);
long count = ObjectSelect.query(Artist.class)
.where(ExpressionFactory.exists(subquery))
.selectCount(context);
{code}
Also we need a way to use expressions from top level query in a subquery. Maybe it can be new expression (like {{Artist.ARTIST_NAME.enclosing()}})
In a first iteration this should support {{EXISTS}} and {{IN}} subqueries.
was:
Currently there is no way to use subqueries in {{SelectQuery}} or {{ObjectSelect}}.
So we need a way to do so, natural way of doing so is to support it in {{Expression}} API.
Simple version can be implemented like this: {code}
ObjectSelect<Painting> subquery = ObjectSelect.query(...);
long count = ObjectSelect.query(Artist.class)
.where(ExpressionFactory.exists(subquery))
.selectCount(context);
{code}
Also we need a way to use expressions from top level query in a subquery. Maybe it can be new expression (like {{Artist.ARTIST_NAME.enclosing()}})
In a first iteration this should support {{EXISTS}} and {{IN}} subqueries.
> Support subqueries in Expression API
> ------------------------------------
>
> Key: CAY-2468
> URL: https://issues.apache.org/jira/browse/CAY-2468
> Project: Cayenne
> Issue Type: Task
> Components: Core Library, Database integration
> Reporter: Nikita Timofeev
> Assignee: Nikita Timofeev
> Priority: Major
> Fix For: 4.2.M1
>
>
> Currently there is no way to use subqueries in {{SelectQuery}} or {{ObjectSelect}}.
> So we need a way to do so in {{Expression}} API.
> Simple version can be implemented like this:
> {code:java}
> ObjectSelect<Painting> subquery = ObjectSelect.query(...);
> long count = ObjectSelect.query(Artist.class)
> .where(ExpressionFactory.exists(subquery))
> .selectCount(context);
> {code}
> Also we need a way to use expressions from top level query in a subquery. Maybe it can be new expression (like {{Artist.ARTIST_NAME.enclosing()}})
> In a first iteration this should support {{EXISTS}} and {{IN}} subqueries.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)