Retrieving by a property in a toMany relation

From: Oscar Picasso (oscgoogl..ahoo.com)
Date: Thu Oct 13 2005 - 09:42:56 EDT

  • Next message: Andrus Adamchik: "Re: Retrieving by a property in a toMany relation"

    Hi,

    Many times I need to retrieve a particular object which is on the "many" end of
    a relation, using one of its properties.

    Example:
    Artist -toMany- Panting

    I want something like that:
    someArtist.paintingByName("A painting name");

    What would be the best way to deal with this kind use case, in terms of memory,
    speed, simplicity, thread safety?

    I have thought of various approaches:
    - using a query. Only retrieves persisted objects if I remember.
    - a HashMap and overriding the relevant setXXX, getXXX, addToXXX, removeFromXXX
    ... so as to update the Map. This one seems to me cumbersome as there many
    methods that could be involved. It would be more feasible if I knew for sure
    that a very limited number of methods are always involved when updating a
    relation.
    - walking through the List associated to the relation and returns the object
    that matches the property. This one seems very inefficient.

    Any other idea?

    Thanks

    Oscar

                    
    __________________________________
    Yahoo! Music Unlimited
    Access over 1 million songs. Try it free.
    http://music.yahoo.com/unlimited/



    This archive was generated by hypermail 2.0.0 : Thu Oct 13 2005 - 09:43:00 EDT