This endpoint permanently removes a product from the database. The operation cannot be undone. All associated data, including category relationships, will be removed due to cascade deletion rules.
{ "timestamp": "2026-03-03T15:45:30", "status": 400, "error": "Bad Request", "message": "Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'", "path": "/products/invalid"}
After deletion, you can verify the product no longer exists:
curl -X GET "http://localhost:8080/products/1" \ -H "Accept: application/json"# Should return 404 Not Found
Permanent Deletion: This operation permanently deletes the product from the database and cannot be undone. Make sure you want to delete the product before calling this endpoint.
Cascade Effects: Due to the @OneToMany relationship with cascade = CascadeType.ALL and orphanRemoval = true on the categories field, all ProductCategory associations will be automatically deleted when the product is deleted.
Idempotency: This endpoint is not idempotent. Attempting to delete the same product twice will result in a 404 Not Found error on the second attempt.
Best Practice: Consider implementing soft deletes (marking products as inactive rather than physically deleting them) if you need to maintain historical records or support undo functionality.