Hi Deepesh! Disclaimer: Note my answer applies to Cayenne version 4.0 (it’s the only version I know and I don’t know the older APIs).
I’m assuming you’re new to Cayenne and inherited an existing project. Cayenne maps a database to a java object graph, and using Cayenne you'll usually have a one-to-one mapping of a database table to an “entity" (usually mapped to a java class). Entities also contain information about how they relate (are joined), those are called “relationships” and are represented by java methods on the entity classes (this will all sound very familiar if you’ve ever used an ORM before). So: You probably (hopefully) already have entities (java classes) called “Person” and “Address”, joined by relationships called “people” and “addresses”. Assuming this is correct, the query you describe can be performed with: --- SelectQuery<Person> query = new SelectQuery<>( Person.class ); query.setQualifier( Person.NAME.outer().eq( “Deep%” ).and( Person.AGE.outer().gt( 18 ) ); List<Person> peopleNamedDeepAndOlderThan18 = someObjectContext.select( query ); — Note the type safety. It’s a thing of beauty, really. Cheers, - hugi > On 26. sep. 2015, at 07:04, Dipesh Jain <dip...@ivgroup.in> wrote: > > I have searched example for SQL joins using apache cayenne but I found > nothing. How can i use selectQuery with Expression for JOINs or I have to > use SQLTemplete or EJBQL Query. > > Like I have a query - > " Select p.name, a.address from Person p RIGHT OUTER JOIN Address a ON > p.personId = a.personId where p.name LIKE 'Deep%' AND p.age > 18 " > > then to write it in cayenne ? > > -- > Thanks and Regards > Deepesh Jain