Hi,
sometimes, i must insert or update records in a table that has
auto-generated column (es: MS Access --> counter)
When i need to save data, first i check if i already have an object that
matck the key that come from user (maybe he has insert it manually, or maybe
is auto-generated.. so i have a null value from the form):
dtOb = DataObjectUtils.objectForPK(dataContext, entity, compoundKey);
If the key is not specified by user, the "compoundKey" is null, and the code
above return also a null DataObject.
Now i know that is the time to create a new record:
dtOb = dataContext.createAndRegisterNewObject(entity);
then, i insert all required values:
dtOb.writeProperty(....)
... BUT NOT the auto-generated column.
When i perform a commit, Cayenne return me an error, because in the
generated INSERT query, is still present the auto-generated column, and the
value assigned is NULL.
How i can tell to cayenne to ignore the column, in way that the generated
INSERT query doesn't contains it?
There are other ways to manage this kind of operation?
Thanks
D.