Page 1 of 1

Upgrade to 3.1.8-GA; can't delete products

Posted: Tue Aug 26, 2014 2:17 pm
by daniel_locious
Hi guys,

Not sure it was existed before upgrade, or is it because my upgrade process was wrong.
In my understanding, DemoSite upgrade usually only need to change blc version on pom.xml, correct?

Anyway, after changed and recompiled, run admin, in product page, click "delete", I got "There was a problem deleting this record".

On backend
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "blc_sku" violates foreign key constraint "fk5b95b7c96d386535" on table "blc_product"
[artifact:mvn] Detail: Key (sku_id)=(1) is still referenced from table "blc_product".

I tried to find the sku page to delete the sku first, but there is no separated sku page?!

Noticed that this issue happened before in May, and has been marked as resolved. Could anyone advise how can I solve this problem?

Regards,

Dan

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Tue Aug 26, 2014 2:28 pm
by daniel_locious
In addition to the above issue, when I try to add a product, after fill in the fields and click save, I got

Unable to add entity for org.broadleafcommerce.core.catalog.domain.ProductImpl


org.broadleafcommerce.common.exception.ServiceException: Unable to add entity for org.broadleafcommerce.core.catalog.domain.ProductImpl
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)

org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:128)

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)



Does this mean the sku_id generator were set to 0 which is conflicted with existing records?

Cheers,

Dan

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Thu Aug 28, 2014 2:25 pm
by daniel_locious
I believe this issue is related to SoftDelete mentioned inhttps://github.com/BroadleafCommerce/BroadleafCommerce/issues/842

However, I don't understand why don't we update blc_product to set default sku id = null? I believe this is the reason that we can't hard delete the SKU. Alternatively, if we want to soft delete sku as well, should give it an archieved flag.

Regards,

Dan

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Mon Sep 01, 2014 1:57 pm
by daniel_locious
Forgot to mention about the database, although I don't really think it's the reason.

My database is Postgres, not sure if all the tests can pass on MySQL? Anyone test this on MySQL?

Cheers,

Dan

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Fri Sep 05, 2014 5:28 am
by daniel_locious
@phillipuniverse

Do you have an idea about this one?

Cheers,

Dan

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Tue Sep 16, 2014 1:52 pm
by daniel_locious
daniel_locious wrote:In addition to the above issue, when I try to add a product, after fill in the fields and click save, I got

Unable to add entity for org.broadleafcommerce.core.catalog.domain.ProductImpl


org.broadleafcommerce.common.exception.ServiceException: Unable to add entity for org.broadleafcommerce.core.catalog.domain.ProductImpl
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)

org.hibernate.exception.ConstraintViolationException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:128)

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "blc_sku_pkey"
Detail: Key (sku_id)=(2) already exists.
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)



Does this mean the sku_id generator were set to 0 which is conflicted with existing records?

Cheers,

Dan



I found the reason for this one:
The import sql for sequence_generator table wasn't loaded for some reason. I tried to re-edit the configure file but still can't load those data; the rest of the import sql files runs well, that's say sql files before and after this sql file, run well. I suspected it's some mis-type-in in the sql, but I copy&paste into my db console and it runs well. So no idea what's happen.

At the moment I hv to manually run the script on dev everytime restart the server, as a workaround.

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Mon Nov 17, 2014 3:12 am
by leosoon
How could I add annotation onto this field without change SkuImpl? I tried to re-inject another SkuExtImpl class to the site and admin, but it doesn't work; the ProductImpl only looks for SkuImpl.

Re: Upgrade to 3.1.8-GA; can't delete products

Posted: Tue Dec 02, 2014 8:21 pm
by phillipuniverse
@leosoon, add a configuration in applicationContext-entity.xml to refer to your SkuExtImpl:

Code: Select all

<bean id="org.broadleafcommerce.core.catalog.domain.Sku" class="com.yourcompany.SkuExtImpl" scope="prototype" />