Object-Relational Mapping load-on-demand

Discussions

Performance and scalability: Object-Relational Mapping load-on-demand

  1. Object-Relational Mapping load-on-demand (7 messages)

    Hi!!

    I wanna know if there are some tool that implement some kind of load-on-demand object, for example:
    If I have an Object Person and this Person have a Collection of others person (familiars) when some object request the familiars of that person, in that moment the familiars loads form database....

    Sorry if it's confuse...but My english is not very clear... je!

    Thanks! if someone understand ;)

    Matute

    Threaded Messages (7)

  2. You should look at the TOPLink product now owned by Oracle. It has a concept of Indirection which is exactly what you're looking for. Bear in mind this is a powerful tool, and therefore takes some time and effort to learn and use.

    Tim
  3. TopLink is open source?[ Go to top ]

    One more question.
    TopLonk is open-source.
    I mean I can use it and don't worried with legal software?? or some of that...

    I'm reading somthing of "Hibernate" it has something like this,
    Proxies and lazy initialization, but i don't know
    if it works with internal instance variables, collections and Maps....

    Well thanks!

    Matute
  4. TopLink is open source?[ Go to top ]

    TOPLink is not open source. It's a software product owned by Oracle. It comes bundled with the Oracle 9i Application Server, or it can be purchased stand-alone. It costs nothing for development, but runs at about $7,000 USD per CPU in a production environment.

    Most people don't even consider TOPLink because of the cost, but if you have a project team with 4-10 developers who are spending 30-40% of there time coding the persistence layer, you can get a return of your investment on TOPLink in a year's time.

    Tim
  5. re: a year's time[ Go to top ]

    I think the ROI is a little bit faster than a year. If you're on a project with 4-10 developers, 7k is peanuts. And for most business applications, i'd say your time is spent closer to 50% of the time working with the persistance layer (work in yoru business layer involves figuring out how to query data from the datastore, and Toplink has some nice APIs to do that....there's a learning curve of course). I think your ROI would be realized in weeks, not a year.

    -Chris
  6. re: a year's time[ Go to top ]

    Chris,

    I agree, I went with some very conservative numbers. It all depends on how many servers/cpus you deploy TOPLink on, and what you consider the cost of the learning curve.

    What I find surprising is even with the quick ROI, how difficult of a sell it can be to use TOPLink. Not necessarily by management, but by the developers themselves!

    Tim
  7. http://www.oreillynet.com/cs/weblog/view/wlg/2872
  8. Do you have a PersonFactory?[ Go to top ]

    Can you use a Factory pattern to do what you want? I'm assuming you're not using EJB. This is what I imagine:

    1. A Person class with a getFamiliars() method. getFamiliars() returns a Collection of Person objects. Person would have a member variable to hold the reference to the collection of familiars, after they're loaded.

    2. A PersonFactory class that encapsulates database access to load Persons. PersonFactory has a method called getFamiliarsForPerson(String personID) that makes the JDBC call to retrieve data and instantiate Persons based on the data returned.

    3. Person.getFamiliars() would check to see if its familiars member variable was null, and (if not) call PersonFactory.getFamiliarsForPerson(), store the returned collection, and then return it to the caller. If the familiars were already cached, getFamiliars() would return the cached collection.

    With the caching you have a staleness issue - if familiars will be added/removed frequently, you'll want to avoid caching or run the add/remove operations through Person so the cache can get updated.

    Hope that helps,

    James