Re: Microsoft SQL Server and random JDBCAdaptor "failed to provide new primary keys for entity" error
Re: Microsoft SQL Server and random JDBCAdaptor "failed to provide new primary keys for entity" error
- Subject: Re: Microsoft SQL Server and random JDBCAdaptor "failed to provide new primary keys for entity" error
- From: "Daniele Corti" <email@hidden>
- Date: Tue, 17 Apr 2007 17:50:53 +0200
2007/4/17, Francis Labrie <email@hidden>:
Hi,
Daniele Corti wrote:
2007/4/13, Francis Labrie <
email@hidden>: I have several WebObjects 5.3.3
/ Java 1.5 applications in production since a long time. These applications are very stable, but sometimes (i.e. 0 to 10 times per week) I get IllegalStateException from the JDBCAdaptor adaptor claiming that is has failed to provide new primary key for an entity. The entity involved is not always the same, and this error seems to popup randomly.
I use the jDTS JDBC driver connected to a Microsoft SQL Server 2000 database using a custom JDBC adaptor plugin that inherits the default MicrosoftPlugIn one. This plugin is stable since a long time.
This is the typical stack trace:
java.lang.IllegalStateException
: Adaptor com.webobjects.jdbcadaptor.JDBCAdaptor@2304c9 failed to provide new primary keys for entity 'Adresse'
at com.webobjects.eoaccess.EODatabaseContext.prepareForSaveWithCoordinator(EODatabaseContext.java:5885)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java
:409)
at com.webobjects.eocontrol.EOEditingContext.saveChanges
(EOEditingContext.java:3226)
...
Did somebody already have this kind of error? I would like to track down and fix this behavior, but I can't figure what's the cause. Did somebody have an explanation?
I had the exactly same error in a scenario:
I usually create tables by EOModeler, I generate the EOModel File and select Syncronize schema! and in my tables I put the primary key not modeled by the eomodel file. It happens to me, that I need to use the primary key as a field of a search (for example of the Order Number), and I've this error. I realize that the problem was that EOModeler don't create primary keys on the tables, but only set UNIQUE (selecting provide primary key generation) while syncronizing the DB. So, when I don't model the primary key (ad default EOModeler set) there's no problem, because the adaptor set it automatically, but when modeling the field it doesn't provide the primary key and throw this exception.
I've fixed the problem by setting the primary key autogeneration on the db tables, so I don't need to thouch them.
I hope this could help, check the EOModel file, and the tables on your db. Fixing them everything should be fine!
Unfortunately, this doesn't seem to be the problem in my case: there is an EO_PK_TABLE table filled with all the needed sequences to generate primary keys.
When I get this error, the entity sequence exists and has been already used in previous saveChanges() calls. This is very strange, and I can't find the reason behind this exception.
probably you still did it, but check your code if you remove the PK field, for any reason. Or maybe, if, deleting an object, you set at null every field, but you don't remove it from the editing context.
Kind regards,
--
Francis Labrie
Saint-Bruno-de-Montarville, Québec, Canada
--
Daniele Corti
AIM: S0CR4TE5
Messenger:
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden