The Artima Developer Community
Sponsored Link

Java Answers Forum
How to retrieve records based on muliple columns using CMR?

3 replies on 1 page. Most recent reply: Nov 18, 2002 10:19 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Ashish A

Posts: 2
Nickname: ashisha
Registered: Nov, 2002

How to retrieve records based on muliple columns using CMR? Posted: Nov 17, 2002 10:58 PM
Reply to this message Reply
Advertisement
I have three tables namely Project,Course & Students. The Project & Course having pk-field prj_id & course_id respectively which is having a foreign key mapping with Students table. These tables formed the 3 different entitiy beans. I have used CMR (Container Managed Relationships) to get the values from the table Students. i.e. getStudents() method has been defined in Project & Course Entity Beans to get the Students based on either the Project Id or Course Id. These method is returning a Collection.

Now I would like to find out the Students based on BOTH Project Id & Course Id entered by user. Currently the possible way which I can see is that to get the two different Collection , one is from Project Entity Bean by Project Id & other is from Course Entity Bean by Course Id and then compare both these collections to get the required the Students. With this approach, it increases the database calls as it has to get the Students by project id and then by course id.

Is this the right approach? and is there any other alternatives which will reduce the database calls?

Please suggest. Thanks in advance.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: How to retrieve records based on muliple columns using CMR? Posted: Nov 17, 2002 11:59 PM
Reply to this message Reply
Seems clear you should narrow the search with a database query instead of getting all the data twice, then doing the filtering.

Ashish A

Posts: 2
Nickname: ashisha
Registered: Nov, 2002

Re: How to retrieve records based on muliple columns using CMR? Posted: Nov 18, 2002 12:59 AM
Reply to this message Reply
Thanks Matt.
The problem here is that Container executes the query for the method getStudents() in Project & Course Entitiy bean. So no where I can change the query because it is container based relationships that I am using it.

Please advice.

Thanks again.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: How to retrieve records based on muliple columns using CMR? Posted: Nov 18, 2002 10:19 PM
Reply to this message Reply
Can you post the code (especially for the beans, at the very least, their interface)? Maybe upon examination, something will come to light. I hope you didn't trade your only cow for these beans, but even if you did, maybe they have a little more magic than you think...

(if you do, be sure to use the java tags mentioned at the right in the "Formatting Your Post" box).

Flat View: This topic has 3 replies on 1 page
Topic: can a method return more than one value Previous Topic   Next Topic Topic: A classt hat will Model a student and University

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use