on 01-06-2008 11:34 PM
Hello Guys,
In one of the webdynpro applications, we had to migrate large amount of data from the other source and so we had over 5000 records in the one of the table. After the data is migrated and application is deployed, I thought it was all ok, but it was the data in between, but not at the end as you would expect. And when it could no longer insert in between, it started throwing the Duplicate Key Exception on ejbCreate method.
The table are created using dictionary DC. We are using SQL Server as the DB and the particular table has the primary key as big int.
Do I have to set the "Interval for Generated Primary keys' option in the ejb-j2ee-engine.xml?
Have you seen like this before? Am I missing something here? Any help would be much appreciated.
Regards,
Muthaiah
Edited by: Muthaiah Ramanathan on Jan 7, 2008 12:34 AM
Hi Muthaiah,
DuplicateKeyException indicates that you are trying to insert a record into a DB table for which another record with the same PK already exists. This is caused by application misbehavior, so check your application logic. You have to avoid calling the entity bean's create method more than once for the same PK.
HTH!
\-- Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, Pavel I had to do the Data migration. But it seems the primary key counter is initialized only during the application is started for the first time.
Before migrating the data I did a test to check if everything was ok and that set the primary key counter in the ejb engine I assume. Then I did the data migration and had few thousand records migrated. But the primary key counter was never refreshed.
Regards,
Muthaiah
For the record (as this issue has been processed also through the regular SAP support channel):
Indeed, the primary key counter is initialized when create() method is invoked for the first time. Its initial value is (max value of the corresponding column in the DB) + 1. From this point on the EJB Container requires exclusive access for updates to the entity bean's DB table. However, in this case it turned out you've already created some entries through the entity bean and then did the data migration, which resulted in DuplicateKeyException at the next call to ejbCreate().
Regards,
\-- Vladimir
User | Count |
---|---|
86 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.