Williams, Beth wrote:
> I am using the "createAndRegisterNewObject()" method from the DataContext to essentially add a new person to our persons objEntity. One of the attributes that is needing to be set is the personId. This >field in the database is sequence number, however, there is no trigger setup to automatically generate this number. What I need to do is find out what the next number in the sequence would be (equivalent to running the following query select person_id.NextVal from dual) so that I can use the setPersonId() method and include this value. Can this be done through Cayenne and if so, what would be the best way of doing this? Thanks.
After the createAndRegisterNewObject(), in the next commitChanges(),
Cayenne will automatically do the fetching of NextVal to get the next
primary key value, assuming that personId is designated as a primary
key. (You can see the NextVal fetch in the log.) You shouldn't have to
worry about it in your code.
Once in a blue moon, you might want to supply a different value for the
primary key, say by letting the user specify it. This is possible with
some extra code, although this probably isn't what you were asking.
This archive was generated by hypermail 2.0.0 : Mon Nov 01 2004 - 13:00:07 EST