Home > Back-end >  Spring Boot Adding to POST RequestBody Object but getting NULL error when adding to db
Spring Boot Adding to POST RequestBody Object but getting NULL error when adding to db

Time:09-06

I am trying to add a unique ID to the request body of an object before writing it to the database (Apache Derby).

PostMapping

I have also tried adding the unique ID in the constructor or in the service portion. It recognizes that I have added this attribute to the object (from print statements), but when it passes to be written to the db I get the below error saying that the ID is NULL (and not the added UID string that printed).

Error

I'd really appreciate any advice on how to solve this or how to better add a UID, because this has completed befuddled me. Thanks!

Edit: added screenshots of service and repo which are just plain-jane. I do not believe they are causing any errors,

Bounty service and repo: Bounty Service Bounty Repo

Bounty class: Bounty class

CodePudding user response:

Have you try debugging you application? Without looking at other class implementation such as BountyService and Bounty class it is difficult to help further.

CodePudding user response:

Needed to remove @GeneratedValue from primary key in Bounty class code

  • Related