RE: ResultSet with ORACLE Stored Procedure OUT Parameter

From: Pirola Davide (davide.pirol..tin.it)
Date: Tue Jan 18 2005 - 10:43:58 EST

  • Next message: moraru_et..pymac.com: "subselect query"

    Hi Andrus,
    yours suggests works fine.
    Thank's a lot!!

    Another question... exist a tutorial / book where i can find detailed information about cayenne?
    I'm very interested in this framework.
    The only documentation available is on web site (www.objectstyle.org/cayenne)?

    :)

    Davide

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: luned́ 17 gennaio 2005 16.32
    To: cayenne-use..bjectstyle.org
    Subject: Re: ResultSet with ORACLE Stored Procedure OUT Parameter

    Hi Davide,

    > When i use "ctxt.objectFromDataRow" i must have an entry in data map
    > xml file?

    > I haven't a corresponding db table for my data... the StoredProcedure
    > return the result of a query!

    Yes. As Cayenne primarily targets at managing object graphs on its own,
    so doing it at the DB level via stored procedures creates certain
    hassles.

    > Which is the xml tag ("db-entity"?"query"?"obj-entity"?)

    You need both (even though you don't have a user table). Just create a
    DbEntity that describes a result set from your stored procedure and
    create an ObjEntity that maps to it (use "Sync with DbEntity" menu to
    speed up this process). Mark it as read-only so that Cayenne doesn't
    attempt to write into a non-existing table.

    BTW there maybe an extra benefit of defining entities this way - if you
    have keys to real tables defined in the stored procedure result, you
    can map relationships via Cayenne.

    Andrus

    On Jan 17, 2005, at 6:18 AM, Pirola Davide wrote:
    > Hi,
    > your code work fine!!
    > Thank's for your suggestion.
    > Now i have another problem. How i can map the resulset readed from
    > stored procedure to my java Object?
    > Here my code:
    > -----------------------------------------------------------------------
    > ---------
    > .
    > .
    > .
    > QueryResult resultsCollection = new QueryResult();
    > // run query
    > ctxt.performQuery(query, resultsCollection);
    > List outList = resultsCollection.getFirstRows(query);
    >
    > if (outList.size() > 0) {
    > Map outParameterValues = (Map) outList.get(0);
    > DataRow dtr = new DataRow(outParameterValues);
    > System.out.println(dtr);
    >
    > User object = (User)ctxt.objectFromDataRow(User.class,
    > dtr, true);
    >
    > }
    > -----------------------------------------------------------------------
    > ---------
    > I have an error when execute the last line ("User object =
    > (User)ctxt.ob...")
    >
    > When i use "ctxt.objectFromDataRow" i must have an entry in data map
    > xml file?
    > Which is the xml tag ("db-entity"?"query"?"obj-entity"?)
    > I haven't a corresponding db table for my data... the StoredProcedure
    > return the result of a query!
    >
    > Thank's
    > :)
    > Davide



    This archive was generated by hypermail 2.0.0 : Tue Jan 18 2005 - 10:43:51 EST