Hi Tim,

if you export the values and just import the generic values, no new primary key values are generated. The data is imported just the way it is.

Therefore the sequence value item for the table is not increased and if you want to create a new item through the user interface, you'll receive an already used primary key value. This is all logical and no failure in the software.

You have two options here:

1. set the sequence value item for the table one higher than your highest value in the loaded data. This can be done using the entity maintenance in webtools.

2. import your data without the primary key values. OFBiz will then generate them from the SEQUENCE_VALUE_ITEM table.

Hope this helps,

Regards,

Michael Brohl
ecomify GmbH
www.ecomify.de


Am 23.12.17 um 21:03 schrieb Boyden, Timothy:
I found the SEQUENCE_VALUE_ITEM table, and the entry for ContactMech had the 
correct next key. It looks like for some reason, ContactMech or TelecomNumber 
is not using that to create the next sequence correctly. I guess for now, I'll 
just keep hitting save until I get to 10042. Hopefully it will save then and 
reset the counter its using.

-Tim

-----Original Message-----
From: Boyden, Timothy [mailto:tboy...@electroswitch.com]
Sent: Saturday, December 23, 2017 2:37 PM
To: user@ofbiz.apache.org
Subject: Entity ID key counter not reset after import from XML

Using Release 16.11.03...

Working on an instance of OFBiz on my home computer. Imported 40 TelecomNumber 
records from my work computer. Went to create a new TelecomNumber record, and 
get:


The Following Errors Occurred:

Exception thrown while creating the "newValue" GenericValue: 
org.apache.ofbiz.entity.GenericEntityException: Error while inserting: 
[GenericEntity:ContactMech][contactMechId,10031(java.lang.String)][contactMechTypeId,TELECOM_NUMBER(java.lang.String)][createdStamp,2017-12-23
 14:33:09.744(java.sql.Timestamp)][createdTxStamp,2017-12-23 
14:33:09.657(java.sql.Timestamp)][lastUpdatedStamp,2017-12-23 
14:33:09.744(java.sql.Timestamp)][lastUpdatedTxStamp,2017-12-23 
14:33:09.657(java.sql.Timestamp)] (SQL Exception while executing the following:INSERT 
INTO dbo.CONTACT_MECH (CONTACT_MECH_ID, CONTACT_MECH_TYPE_ID, INFO_STRING, 
LAST_UPDATED_STAMP, LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, 
?, ?, ?, ?, ?) (Violation of PRIMARY KEY constraint 'PK_CONTACT_MECH'. Cannot insert 
duplicate key in object 'dbo.CONTACT_MECH'. The duplicate key value is (10031).)) (Error 
while inserting: 
[GenericEntity:ContactMech][contactMechId,10031(java.lang.String)][contactMechTypeId,TELECOM_NUMBER(java.lang.String)][createdStamp,2017-12-23
 14:33:09.744(java.sql.Timestamp)][createdTxStamp,2017-12-23 
14:33:09.657(java.sql.Timestamp)][lastUpdatedStamp,2017-12-23 
14:33:09.744(java.sql.Timestamp)][lastUpdatedTxStamp,2017-12-23 
14:33:09.657(java.sql.Timestamp)] (SQL Exception while executing the following:INSERT 
INTO dbo.CONTACT_MECH (CONTACT_MECH_ID, CONTACT_MECH_TYPE_ID, INFO_STRING, 
LAST_UPDATED_STAMP, LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP) VALUES (?, ?, 
?, ?, ?, ?, ?) (Violation of PRIMARY KEY constraint 'PK_CONTACT_MECH'. Cannot insert 
duplicate key in object 'dbo.CONTACT_MECH'. The duplicate key value is (10031).))) The 
next key value should have been reset to 10041 after the import, but it wasn't.

Is there a quick way for me to reset the next key value?

Thanks,

Tim


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to