Maybe I was not clear enough:If you import data from another system, containing the primary key, you won't get a new sequence value from the system you import to. It just imports with the pk in the data. The sequence value for the pk is therefore not increased.
In case of TelecomNumber, the primary key is a contactMechId, which is the pk of the ContactMech entity. So you have to look at the sequence value item for ContactMech. Importing telecom numbers alone are not sufficient, the database model is a bit more sophisticated in this case. You have a ContactMech with a purpose TELECOM_NUMBER and a detail entity TelecomNumber.
I recommend to have a closer look at the data model. It will make some things clearer. I also recommend the new data model book of 2017, see https://cwiki.apache.org/confluence/display/OFBIZ/Data+Model+Diagrams.
Regards, Michael Am 24.12.17 um 13:03 schrieb Boyden, Timothy:
No, this was a new telephone record, being added to a new party, not from the import. The import was of 10 parties and 40 contact records. To add the new phone number for the new party, I had to hit save 41 times, to get to an id value that it would accept. That is certainly not acceptable, the system should know what the next key available to use is. It doesn't look like the TelecomNumber uses the SEQUENCE_VALUE_ITEM table to store its next key, so it must be using some other method, that isn't working correctly. -Tim -----Original Message----- From: Michael Brohl [mailto:michael.br...@ecomify.de] Sent: Sunday, December 24, 2017 6:45 AM To: user@ofbiz.apache.org Subject: Re: Entity ID key counter not reset after import from XML 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
smime.p7s
Description: S/MIME Cryptographic Signature