You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by "Michael Bouschen (JIRA)" <ji...@apache.org> on 2014/07/10 21:41:04 UTC

[jira] [Commented] (JDO-730) Creating the innerjoin without relationship between objects

    [ https://issues.apache.org/jira/browse/JDO-730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14057845#comment-14057845 ] 

Michael Bouschen commented on JDO-730:
--------------------------------------

JDOQL supports this kind of queries using a feature called unconstrained variables (see chapter 14.6.5 in the specification).

Class1 is the class mapped to Table1 and Class2 is mapped to Table2. The query uses Class1 as the candidate class of the query and declares a variable b of type Class2. The variable b is not bound by a contains clause, so ths is called an unconstrained variable.

Query q = pm.newQuery(Class1.class);
q.setFilter("this.z == b.w"); 
q.setResult("this.x, b.y")
q.declareVariables("com.xyz.Class2 b");
Collection result = (Collection )q.execute();

Here is the single-string version of the query:
  select this.x, b.y from com.xyz.Class1 where this.z == b.w variables com.xyz.Class2 b

Hope this helps.

> Creating the innerjoin without relationship between objects
> -----------------------------------------------------------
>
>                 Key: JDO-730
>                 URL: https://issues.apache.org/jira/browse/JDO-730
>             Project: JDO
>          Issue Type: Wish
>          Components: api
>    Affects Versions: JDO 3.1-rc1
>            Reporter: RaviRaja
>            Assignee: Michael Bouschen
>             Fix For: JDO 3.1
>
>
> Cannot make innerjoin like this without relationship:
> select a.x, b.y from Table1 as a INNER JOIN Table 2 as b ON a.z=b.w
> Note: a.z and b.w are not primary and foreign keys



--
This message was sent by Atlassian JIRA
(v6.2#6252)