You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by just_a_kid <ju...@hotmail.com> on 2007/07/09 03:51:19 UTC

How to use left outer join / left join in cayenne?

Hi,

 Can somebody give me example /teach me how do we perform left outer join
using cayenne?
 I have been doing this using Expression.fromString() but it doesnt work.

 2nd thing , can we perform direct native SQL dialect in cayenne? ( for
example if we want to perform " select * from table_a where rownum <=10 )
and 
 how do we get java.sql.Connection in cayenne? 

  hanks
-- 
View this message in context: http://www.nabble.com/How-to-use-left-outer-join---left-join-in-cayenne--tf4046745.html#a11494856
Sent from the Cayenne - Dev mailing list archive at Nabble.com.


Re: How to use left outer join / left join in cayenne?

Posted by Andrus Adamchik <an...@objectstyle.org>.
Sorry - missed your email. I guess cause it was on the dev list vs.  
user :-) Anyways...

>  Can somebody give me example /teach me how do we perform left  
> outer join
> using cayenne?
>  I have been doing this using Expression.fromString() but it doesnt  
> work.

So far the Expression API doesn't support OUTER joins. All expression  
paths resolve as INNER joins. We are developing two parallel  
approaches to that in Cayenne 3.0: (1) adding join semantics to  
Cayenne Expressions - there are patches for that already, but they  
are not yet committed and (2) Implementing EJBQL query [1] - this  
will be included in upcoming 3.0M1 release.

>  2nd thing , can we perform direct native SQL dialect in cayenne?  
> ( for
> example if we want to perform " select * from table_a where rownum  
> <=10 )
> and
>  how do we get java.sql.Connection in cayenne?

You can use SQLTemplate query [2]. With it you will still use  
DataContext - you won't need direct access to JDBC connection.  
However if you are still interested in doing raw JDBC with Cayenne  
stack, you can:

   DataSource ds = context.getParentDataDomain().getNode 
("mydatanode").getDataSource();
   Connection c = ds.getConnection();

Cheers,
Andrus


[1] http://cayenne.apache.org/doc/ejbqlquery.html
[2] http://cayenne.apache.org/doc20/sqltemplate-query.html

On Jul 9, 2007, at 4:51 AM, just_a_kid wrote:

>
> Hi,
>
>  Can somebody give me example /teach me how do we perform left  
> outer join
> using cayenne?
>  I have been doing this using Expression.fromString() but it doesnt  
> work.
>
>  2nd thing , can we perform direct native SQL dialect in cayenne?  
> ( for
> example if we want to perform " select * from table_a where rownum  
> <=10 )
> and
>  how do we get java.sql.Connection in cayenne?
>
>   hanks
> -- 
> View this message in context: http://www.nabble.com/How-to-use-left- 
> outer-join---left-join-in-cayenne--tf4046745.html#a11494856
> Sent from the Cayenne - Dev mailing list archive at Nabble.com.
>
>