Searching OO Associations with RDBMS Persistence Models
- From: "Richie" <richie.chauhan@xxxxxxxxx>
- Date: 1 May 2006 12:22:14 -0700
Hi all,
What is the best way to implement the following search
Give me all companies that start with "Micro" in Seattle, Washington
Class Diagram Below (The DB Diagram is also the same, where Location
has a companyID referencing a Company)
+---------+
| Company |
+---------+
|1
|
|1..*
+----------+
| Location |
+----------+
"Company is located at location X. Company has at least one location."
"Location belongs to Company X"
The company class implements the association through
Class Company
{
String companyName;
Set locations;
public void addLocation(location)
{};
}
******The part that gets me is this.
The typical search in this scenario is
Give me all companies that start with "Micro" in Seattle, Washington
This means that the search is across two classes - Company AND Location
************************
In the database world, this is a simple join across two tables.
*************************
I've spent several hours on the lists, and have read a number of posts
that reference the same issue, but came across none that answered it
practical terms.
So I'd like to preface the question by saying that if the only
persistence model available to use was an RDBMS and OO was the only
design methodology. Given that, what is the best methodology for
solving the problem.
What is the correct correlation of this in a Object Oriented World.
1) Do I create another class called CompanyLocations that does the
search and creates the objects as needed. This doesn't work too well in
my opinion as the relationship does extend further to Locations have
Employees...would this mean that I would need a CompanyLocationEmployee
Class for searches?
2) Do I create a method search() in COmpany that returns all Companies
that start with "Micro" and then loop through these to search for
locations that match Seattle, WA?
3) Do I fudge the Object Orientation, in Company and create a
search(companyName, city, state) method that searches across the
tables? And creates the necessary location instances as well?
4) Am I making a mountain out of a mole hill?
Thanks in advance
Richie
.
- Follow-Ups:
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Robert Martin
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Bart Wakker
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Laurent Bossavit
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Patrick May
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Alfredo Novoa
- Re: Searching OO Associations with RDBMS Persistence Models
- From: Alfredo Novoa
- Re: Searching OO Associations with RDBMS Persistence Models
- From: H. S. Lahman
- Re: Searching OO Associations with RDBMS Persistence Models
- From: frebe73
- Re: Searching OO Associations with RDBMS Persistence Models
- Prev by Date: Re: Managing multiple instances
- Next by Date: System Models, Time Simulation & Dynamic Charts
- Previous by thread: What Lies Beneath-Feature Article in Better Software Magazine
- Next by thread: Re: Searching OO Associations with RDBMS Persistence Models
- Index(es):
Relevant Pages
|