You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by yunus <co...@gmail.com> on 2012/04/27 12:01:45 UTC

Fetching data from two related tables simultaneoulsy

Hi,
i have problem..I want to fetch data from two tables which are inter related
through primary key

Scenario is:
I have table Applicant in which there are attribute "name" & "ration_Id" and
other table is Certificate which include attribute "status".Now i want to
fetch data from both tables on the basis of "EnrolmentId" which is primary
key of Applicant table and foreign key for Certificate and (then validation
will be applied on obtained list ) how to store that list i.e*.list type*
In Sql..it can be like this
"Select a.name,a.ration_Id,c.status from Applicant a,Certificate c where
a.enrolmentI=c.enrolmentId"

But i want to know how to write it in Cayenne.

--
View this message in context: http://cayenne.195.n3.nabble.com/Fetching-data-from-two-related-tables-simultaneoulsy-tp3943892p3943892.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Fetching data from two related tables simultaneoulsy

Posted by yunus <co...@gmail.com>.
But here how we are finding the status and relating the table with
Certificate????

--
View this message in context: http://cayenne.195.n3.nabble.com/Fetching-data-from-two-related-tables-simultaneoulsy-tp3943892p3943951.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Fetching data from two related tables simultaneoulsy

Posted by Aristedes Maniatis <ar...@maniatis.org>.
If your question is about performance, then:

   http://cayenne.apache.org/doc/prefetching.html



If your question is about just getting the data, then

SelectQuery q = new SelectQuery(Applicant.class);
List applicants = content.performQuery(q);

foreach(applicants as a) {
  a.getEnrolments()....
}

Ari


On 27/04/12 8:01pm, yunus wrote:
> Hi,
> i have problem..I want to fetch data from two tables which are inter related
> through primary key
>
> Scenario is:
> I have table Applicant in which there are attribute "name"&  "ration_Id" and
> other table is Certificate which include attribute "status".Now i want to
> fetch data from both tables on the basis of "EnrolmentId" which is primary
> key of Applicant table and foreign key for Certificate and (then validation
> will be applied on obtained list ) how to store that list i.e*.list type*
> In Sql..it can be like this
> "Select a.name,a.ration_Id,c.status from Applicant a,Certificate c where
> a.enrolmentI=c.enrolmentId"
>
> But i want to know how to write it in Cayenne.
>
> --
> View this message in context: http://cayenne.195.n3.nabble.com/Fetching-data-from-two-related-tables-simultaneoulsy-tp3943892p3943892.html
> Sent from the Cayenne - User mailing list archive at Nabble.com.

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A