EntityValueBase Error with no idear

Got a error

10:16:47.200  WARN oquiWorker-5           
 o.moqui.i.e.EntityValueBase Error in secondary sequenced ID converting SeqId [ALL] in field 
[regionGeoCode] from entity [mantle.product.ProductCalculatedInfo] to a number: 
java.lang.NumberFormatException: For input string: "ALL" 

Entity definition:

    <entity entity-name="ProductCalculatedInfo" package="mantle.product" cache="never">
        <field name="productId" type="id" is-pk="true"/>
        <field name="regionGeoCode" type="id" is-pk="true"/> `Preformatted text`
        <field name="totalQuantityOrdered" type="number-decimal"/>
        <field name="totalTimesViewed" type="number-integer"/>
        <field name="averageCustomerRating" type="number-decimal"/>
        <relationship type="one" related="mantle.product.Product"/>

To seperate calculated infor from one place to another for a product, added one primary key. But with some finding and updating non-primary fields, giving this error. Tried to read the code, it somehow tries to convert a string to a number, that would be error of course, but why? why is it converting? should not I use text as primary key?

the type of the regionGeoCode was ‘text-short’, then after sometime there are some entities created, then I changed it to type ‘id’. this coulde be reason?

Does this error happen on a new database that hasn’t had the:

I know that problems can happen when a primary key is added. Maybe instead of using the same name for the new primary key, change the name of the field.

You can also checkout the code here: moqui-framework/framework/src/main/groovy/org/moqui/impl/entity/EntityValueBase.java at df5e4cc06bb68b71d96e69110a6588d3b37fc679 · moqui/moqui-framework · GitHub

Sorry that’s all the time I’ve got at the moment. Good luck

I followed your suggestion and found some other ways out.
I guess adding a new primary key to a existing table is not a good idea. Or the workaround should for example be adding a new table, witch having one of the prime key as the foreign key point to the wanted table.

The error mentions a secondary sequenced ID, meaning there is a call to generate secondary sequenced ID on the EntityValue object, or calling an entity-auto service with no value for regionGeoCode… possibly in mantle-usl services or SimpleScreens screens OOTB which do not know about this additional primary key field. If there is an existing value in the DB with text and not a number, it blows up. You can look at the call stack or artifact stack logged to see where it is happening.

In general, I’d highly recommend against this sort of data model change unless you want to change all code related to it, and even then maybe better to create a new entity.

yes, better to create a new entity.