We're updating the issue view to help you get more done. 

Cannot create new FacilityTypeApprovedProduct

Description

Description:
I am not sure but I think currently there is no way to create new FTAP. The serializer of ProgramOrderable does not add ID to json so when PO is deserializer, Hibernate think that this is a new instance and because cascade options are not set it throw this exception

input json:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 { "facilityType":{ "id":"53604cbd-99f6-4808-a1f4-a1e8b780c9b6", "code":"zon", "name":"Zone", "description":"", "displayOrder":1, "active":true }, "programOrderable":{ "programId":"09a57a37-c0ce-44d6-ab13-de92ffb54557", "orderableId":"de768203-8fed-4cbc-bd15-bc9a754172d1", "orderableDisplayCategoryId":"2021a399-d6fd-4834-9dbf-22b93274613b", "orderableCategoryDisplayName":"Tablets & Capsules", "orderableCategoryDisplayOrder":30, "active":true, "fullSupply":true, "displayOrder":4, "dosesPerPatient":1, "pricePerPack":0.00 }, "maxPeriodsOfStock":"3", "minPeriodsOfStock":"0", "emergencyOrderPoint":"" }

response:

1 2 3 4 5 6 7 8 { "timestamp" : "2017-04-11T14:21:59.339+0000", "status" : 500, "error" : "Internal Server Error", "exception" : "org.springframework.dao.InvalidDataAccessApiUsageException", "message" : "org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : org.openlmis.referencedata.domain.FacilityTypeApprovedProduct.programOrderable -> org.openlmis.referencedata.domain.ProgramOrderable; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation : org.openlmis.referencedata.domain.FacilityTypeApprovedProduct.programOrderable -> org.openlmis.referencedata.domain.ProgramOrderable", "path" : "/api/facilityTypeApprovedProducts" }

Environment

None

Status

Assignee

Mateusz Kwiatkowski

Reporter

Łukasz Lewczyński

Labels

None

Story Points

5

Time tracking

24h

Components

Sprint

None

Fix versions

Priority

Blocker