Page 1 of 1

Cannot delete product in admin

Posted: Thu Mar 13, 2014 7:02 am
by realstone
Hi,

I try to delete product created by the demo site, it shows the message " There was a problem delete the record" and the exception stack like below. From my understanding, the product should be simply marked as Archived = 'Y', not sure why here it is trying to do hard delete. Any help will be appreciated.


ERROR] 21:49:42 SqlExceptionHelper - Cannot delete or update a parent row: a foreign key constraint fails (`ubestbuyweb`.`blc_product`, CONSTRAINT `FK5B95B7C96D386535` FOREIGN KEY (`DEFAULT_SKU_ID`) REFERENCES `BLC_SKU` (`SKU_ID`))
[ERROR] 21:49:42 DynamicEntityRemoteService - Problem removing org.broadleafcommerce.core.catalog.domain.Product
org.broadleafcommerce.common.exception.ServiceException: Problem removing entity : org.hibernate.exception.ConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`ubestbuyweb`.`blc_product`, CONSTRAINT `FK5B95B7C96D386535` FOREIGN KEY (`DEFAULT_SKU_ID`) REFERENCES `BLC_SKU` (`SKU_ID`))
at org.broadleafcommerce.openadmin.server.service.persistence.module.BasicPersistenceModule.remove(BasicPersistenceModule.java:960)
at org.broadleafcommerce.openadmin.server.service.persistence.PersistenceManagerImpl.remove(PersistenceManagerImpl.java:670)
at org.broadleafcommerce.openadmin.server.service.DynamicEntityRemoteService$5.execute(DynamicEntityRemoteService.java:204)
at org.broadleafcommerce.openadmin.server.service.DynamicEntityRemoteService$5.execute(DynamicEntityRemoteService.java:199)
at org.broadleafcommerce.openadmin.server.service.persistence.PersistenceThreadManager.operation(PersistenceThreadManager.java:33)
at org.broadleafcommerce.openadmin.server.service.DynamicEntityRemoteService.remove(DynamicEntityRemoteService.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy173.remove(Unknown Source)
at org.broadleafcommerce.openadmin.server.service.AdminEntityServiceImpl.remove(AdminEntityServiceImpl.java:660)
at org.broadleafcommerce.openadmin.server.service.AdminEntityServiceImpl.removeEntity(AdminEntityServiceImpl.java:161)
at org.broadleafcommerce.openadmin.web.controller.entity.AdminBasicEntityController.removeEntity(AdminBasicEntityController.java:440)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
......

Re: Cannot delete product in admin

Posted: Thu Mar 13, 2014 10:08 am
by phillipuniverse
What version?

Re: Cannot delete product in admin

Posted: Thu Mar 13, 2014 5:58 pm
by realstone
The latest version from trunk

Re: Cannot delete product in admin

Posted: Sat Mar 15, 2014 3:41 pm
by nieky
Same issue. Need to delete records from some tables:

blc_sku
blc_product_featured
blc_product
+more others.

I tried to delete manually, but catch cyrcled error - can't delete from 2 tables with next issues:
Cannot delete or update a parent row: a foreign key constraint fails (`broadleaf`.`blc_sku`, CONSTRAINT `FK28E82CF77E555D75` FOREIGN KEY (`DEFAULT_PRODUCT_ID`) REFERENCES `blc_product` (`PRODUCT_ID`))
Cannot delete or update a parent row: a foreign key constraint fails (`broadleaf`.`blc_product`, CONSTRAINT `FK5B95B7C96D386535` FOREIGN KEY (`DEFAULT_SKU_ID`) REFERENCES `blc_sku` (`SKU_ID`))

I also tried to set default_sku_id=null in blc_product

And at the end i deleted after removing 2 foreign keys:

alter table blc_product drop foreign key FK5B95B7C96D386535
alter table blc_sku drop foreign key FK28E82CF77E555D75



So if you havent time you can use my suggestions...

Re: Cannot delete product in admin

Posted: Sun Mar 16, 2014 7:02 am
by realstone
Thanks a lot for your suggestion nieky.
Yes, by using your way I can delete the records from the database. However, my idea is trying to create a record through Admin UI and delete the record. It seems every time when a new product is created, a default SKU is assigned to the product. So if I try to delete the product, it will validate the foreign key constraint and failed for deleting the record.

From what I read for the doc, it should do a soft delete which set the Archieve field to 'true' and not perform the actual hard delete on the product. I am not sure why my delete action go to do the hard delete.

Can anyone from Broadleaf clarify a little bit on this? It is all related to verson 3.1.0-GA

Re: Cannot delete product in admin

Posted: Sun Mar 23, 2014 7:36 pm
by phillipuniverse
Can you open an issue for this at https://github.com/BroadleafCommerce/BroadleafCommerce? I would like to get this specifically on the radar. We have a somewhat related issue at https://github.com/BroadleafCommerce/Br ... issues/754