I'd vote for option 3. Although it requires a lot code, it allows you to
avoid writing any Oracle specific SqlSelectQueries. Letting the Cayenne
internals handle this we definitely be the preferred approach.
Maybe you can post what you have? There maybe some shortcuts that will
help you slash away some of that code.
----- Original Message -----
From: "Bryan Lewis" <brya..aine.rr.com>
Sent: Monday, May 03, 2004 11:46 AM
Subject: Re: how to specify objectId for new object
> Eric Schneider <eric <at> centralparksoftware.com> writes:
> > > But what if we (rarely) want to let the user specify the new object's
> > You can do this by adding the pk columns as object attributes in your
> > entity. The modeler leaves these pk columns out of the object entity by
> > default. But, there is nothing that will stop you from adding them
> > yourself. Setup this way, Cayenne will assume that the user will
> > the value. Just set the property like you'd set any other.
> Thanks! Works fine.
> Out of curiosity... if I do that and I occasionally want to go back to the
> generated value, what's the best way to get an auto-generated pk in my
> I've played with a few approaches, mostly to learn more about Cayenne.
> 1. Doing a direct SQL query to the Oracle sequence -- a SqlSelectQuery
> with "select pk_employee.nextval from dual". This works fine but is non-
> portable of course.
> 2. The SqlSelectQuery has been deprecated in favor of the new SQLTemplate,
> I couldn't make the template approach work for this. It expects to return
> DataObjects or else return nothing. Given the same SQL string it returned
> hollow DataObject with no pk. If the SqlSelectQuery goes away, how should
> queries that don't return data objects?
> 3. I managed to get an auto-generated pk portably with a series of calls
> DataMap, DataNode, EntityResolver, DbEntity and PkGenerator. It worked
> seemed overly complicated; I was probably doing it the hard way. What's
> usual practice?
> Thanks again.
This archive was generated by hypermail 2.0.0 : Mon May 03 2004 - 15:48:49 EDT