Page 1 of 1

id_val in sequence generator is not getting updated

Posted: Sun Nov 30, 2014 1:25 am
by karthik.thombarapu
Hi philip,

Sequence Generator is getting reset or the update is not happening so once after restart after setting the
blPU.hibernate.hbm2ddl.auto=validate or None it is throwing duplicate entry issue.

We tried by setting in the development.properties but that did't work..
detect.sequence.generator.inconsistencies=true
auto.correct.sequence.generator.inconsistencies=true

We have 3.1.8 code base and we tried to add product, image after doing create drop it works and then later after killing the tomcat we set it to None then once after restart later if we add a product or an SKU it is not adding rather it is throwing the below and see in the DB that the sequences are not getting updated.

Caused by: org.broadleafcommerce.openadmin.server.service.persistence.PersistenceException: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: Duplicate entry '99952' for key 'PRIMARY'
at org.broadleafcommerce.openadmin.server.service.persistence.module.provider.MediaFieldPersistenceProvider.populateValue(MediaFieldPersistenceProvider.java:145)
at org.broadleafcommerce.openadmin.server.service.persistence.module.BasicPersistenceModule.createPopulatedInstance(BasicPersistenceModule.java:300)
at org.broadleafcommerce.openadmin.server.service.persistence.module.BasicPersistenceModule.createPopulatedInstance(BasicPersistenceModule.java:227)
at com.broadleafcommerce.enterprise.workflow.admin.service.handler.ProductCustomPersistenceHandler.add(ProductCustomPersistenceHandler.java:82)

Can you please help me..thanks.
I verified BLC forum
viewtopic.php?f=14&t=3051
viewtopic.php?f=11&t=3180

Re: id_val in sequence generator is not getting updated

Posted: Tue Dec 02, 2014 7:48 pm
by phillipuniverse
What database are you using?

Try this:

1. Ensure that there is nothing anywhere in any properties files for blPU.hibernate.hbm2ddl.auto=create
2. Start up the server
3. Look at the value of SEQUENCE_GENERATOR
4. Create a new product/sku/whatever
5. Look at the value of SEQUENCE_GENERATOR (it should be increased by 50)
6. Shut down the server
7. Start back up
8. Look at the value of SEQUENCE_GENERATOR (should be the same as step 5)

If I am reading you right, on step 5 the value in SEQUENCE_GENERATOR never increases by 50?

By the way, in 3.1 and below there is some weirdness with how Hibernate is using the value in SEQUENCE_GENERATOR where it actually uses the value as a 'high' instead of a 'low'. This is fixed in Broadleaf 3.2 as documented in https://github.com/BroadleafCommerce/Br ... issues/786 and the issue that it links out to. You might need to set the SEQUENCE_GENERATOR number higher.