Re: Searching Object Cache

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Nov 07 2003 - 11:04:55 EST

  • Next message: Andrus Adamchik: "Re: one app, two db types?"

    Hi Bret,

    If I understand your description correctly, what you need to do is to
    manually create an ObjectId from the flat file data for each Obj1 and
    call "DataContext.registeredObject(..)":

    http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
    access/
    DataContext.html#registeredObject(org.objectstyle.cayenne.ObjectId)

    E.g.

    int id = ... // read from file
    ObjectId id = new ObjectId(Obj1.class, "idName", id);
    Obj1 object = (Obj1) dataContext.registeredObject(id);

    Andrus

    On Nov 7, 2003, at 10:22 AM, Bret Gregory wrote:

    > I know that this topic has been discussed before and I am aware that
    > Cayenne
    > is working as intended, but I am trying to figure out a way to look at
    > the
    > objects that cayenne has either previously created or fetched before it
    > looks at whats in the DB.
    >
    > The scenario that I am running into is as follows:
    >
    > I am processing a flat file. On each line you have obj1 + obj2. obj1
    > has a
    > to-many relationship to obj2. The key for object 1 is not
    > auto-generated.
    >
    > For example:
    > Obj1-ABC Obj2-123
    > Obj1-ABC Obj2-345
    > Obj1-ABC Obj2-678
    > Etc.
    >
    > For each of these lines I want to fetch Obj1 and/or create it if
    > necessary.
    >
    > On each subsequent line I would like the Obj1 that I found/created to
    > be
    > returned.
    >
    > The problem is that if Obj1 was created and it is in memory then each
    > subsequent line will not find it in the DB and thus create a duplicate.
    > This obviously causes a problem when you try to insert the data into
    > the DB
    > and the primary keys are duplicated.
    > I would prefer not to commit after the creation of each new Obj1 since
    > I
    > could have 1000s of Obj1's in the FF.
    >
    > So I am looking for a work around where this scenario would be
    > supported.
    > Thanks!
    >



    This archive was generated by hypermail 2.0.0 : Fri Nov 07 2003 - 11:04:59 EST