Closed TheTharz closed 6 months ago
When testing the endpoint http://localhost:8081/lifepill/v1/item/get-all-items
, the following response is received in Postman:
{
"code": 201,
"message": "SUCCESS",
"data": [
{
"itemId": 19,
"brandId": 3,
"itemName": "Item 9",
"sellingPrice": 50.99,
"itemBarCode": "901234567890",
"supplyDate": "2024-04-11T18:30:00.000+00:00",
"supplierPrice": 48.99,
"itemManufacture": "Manufacturer I",
"itemQuantity": 419.0,
"itemCategoryName": "Vitamins and Supplements",
"itemCategoryId": 4,
"measuringUnitType": "GRAM",
"manufactureDate": "2023-08-31T18:30:00.000+00:00",
"expireDate": "2025-08-31T18:30:00.000+00:00",
"purchaseDate": "2024-04-11T18:30:00.000+00:00",
"warrantyPeriod": "9 years",
"rackNumber": "I9",
"discountedPrice": 49.99,
"discountedPercentage": 50.0,
"warehouseName": "Warehouse I",
"itemImage": "item9_image.jpg",
"itemDescription": "Description for Item 9",
"stock": true,
"freeIssued": true,
"discounted": false,
"specialCondition": false
}
]
}
This response indicates that the endpoint works correctly under certain conditions.
Please check the current state of the Item
table in the database to ensure that the branchId
field is not null for any records. If any records have a null branchId
, this error will occur.
To check for null values in the branchId
column, you can use the following SQL query:
SELECT * FROM Item WHERE branchId IS NULL;
If any records are returned, update them to ensure that branchId
has a valid non-null value. This should resolve the error.
Item
table does not contain any null values for branchId
.http://localhost:8081/lifepill/v1/item/get-all-items
endpoint to ensure it returns the correct response without any errors.This fix ensures that null values can be handled properly, preventing the exception and allowing the endpoint to return all items as expected.
Thank you!
GitHub Issue: Error Retrieving All Items - Null Value Assigned to Primitive Property
Description
When attempting to retrieve all items from the database using the endpoint
http://localhost:8081/lifepill/v1/item/get-all-items
, an error occurs. The error message is as follows:This endpoint was previously working fine.
Steps to Reproduce
http://localhost:8081/lifepill/v1/item/get-all-items
.Expected Behavior
The endpoint should return a list of all items without any errors.
Actual Behavior
An error is thrown indicating that a null value was assigned to a property of primitive type
branchId
in theItem
entity.Possible Cause
The error indicates that a null value is being assigned to a primitive type property (
branchId
) in theItem
entity. Since primitive types in Java cannot be null, this results in an exception. This issue could be due to:branchId
field is null.branchId
.Suggested Fix
Item
table have non-null values for thebranchId
column.branchId
field in theItem
entity is mapped correctly and consider using a wrapper type (Integer
) instead of a primitive type (int
) to allow for null values.branchId
when inserting or updating records in the database.Logs
Please address this issue as soon as possible, as it is affecting the retrieval of items from the database.
Thank you!