When you do migration from one version of commerce to the next or any other scenarios or due to data load scenarios some times the keys table counters are messed and causes lot of errors in application server logs when using those corresponding EJB's.
A lot of discretion is warranted when doing stuff to the keys table e.g. counter should be greater than the lower bound and lesser than the upper bound
You can generate the SQL statements from the script below and run them against the corresponding commerce schema where the issue was found.
SQL Script to see which tables might need to be fixed:
select 'select max(' || columnname||')+1 - (select counter from keys where tablename = '''|| tablename||'''), '''|| tablename || ''' from ' || tablename from keys
SQL script to do the actual updates:
select concat(concat(concat('update keys set counter=',concat(concat(
A lot of discretion is warranted when doing stuff to the keys table e.g. counter should be greater than the lower bound and lesser than the upper bound
You can generate the SQL statements from the script below and run them against the corresponding commerce schema where the issue was found.
SQL Script to see which tables might need to be fixed:
select 'select max(' || columnname||')+1 - (select counter from keys where tablename = '''|| tablename||'''), '''|| tablename || ''' from ' || tablename from keys
SQL script to do the actual updates:
select concat(concat(concat('update keys set counter=',concat(concat(