Re: JDBCAdaptor failed to provide new primary keys
Re: JDBCAdaptor failed to provide new primary keys
- Subject: Re: JDBCAdaptor failed to provide new primary keys
- From: Jon Kleiser <email@hidden>
- Date: Tue, 9 Sep 2003 16:01:32 +0200
Thanks for replies and comments!
I've settled for the following temporary workaround, which doesn't
seem to have too many troublesome side effects:
I've split my "insert-new-record" method into two cases: When the
mentioned numeric value is not 0, I do things the old way
(SwUndervismelding u = new SwUndervismelding(); ec.insertObject(u);
u.setThis(v1); u.setThat(v2); ...). When the value is 0, on the other
hand, I do this:
String modelName = ...;
EOModel model = EOModelGroup.defaultGroup().modelNamed(modelName);
EODatabaseContext dbContext =
EODatabaseContext.registeredDatabaseContextForModel(model, ec);
EODatabaseChannel dbChannel = dbContext.availableChannel();
EOAdaptorChannel adChannel = dbChannel.adaptorChannel();
EOEntity entity = model.entityNamed("SwUndervismelding");
boolean openCloseNeeded = ! adChannel.isOpen();
if (openCloseNeeded) adChannel.openChannel();
NSMutableDictionary row = new NSMutableDictionary();
// Setting all pk and other values ...
row.setObjectForKey(v1, "thiskey");
row.setObjectForKey(v2, "thatkey");
...
adChannel.insertRow(row, entity);
if (openCloseNeeded) adChannel.closeChannel();
/Jon
Hi,
I just noticed a problem in our WO (5.1.3) application when trying
to insert a new SwUndervismelding (extends EOGenericRecord) into the
editing context. In the eomodel, this entity has a compound primary
key consisting of several NSString (S) and NSNumber (i) columns. If,
in the newly created SwUndervismelding, one of those (pk) NSNumbers
has the numeric value 0, we get the following exception when trying
to save chnges:
java.lang.IllegalStateException: Adaptor
com.webobjects.jdbcadaptor.JDBCAdaptor@4fc301 failed to provide new
primary keys for entity 'SwUndervismelding'
As long as this number is not 0, everything works fine. We are using
the Oracle jdbc thin adapter. Is there a tidy solution to this
problem?
Sincerely,
Jon Kleiser
--
---------------------------------------------------------------------
Jon Kleiser / SUAF / USIT / University of Oslo / Norway
Mail: email@hidden / Tel: +47-22852804 / Fax: +47-22852970
---------------------------------------------------------------------
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.