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 : Mon Jan 17 2005 - 10:31:51 EST