Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Foreign Key in JSON post request keeps coming up null.

 
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Student Class



I also have a School class




I'm posting a JSON post request, and everything is posting except for foreign key for the school ID.  It comes up NULL no matter how I insert it.




   {
     
       "studentId": "S2762",
        "school":{
            "id":1
        },
       "firstName": "David",
       "lastName": "Miller",
       "restrictedReason": "Not Applicable ",
       "ticketNumber":"7743",
       "restricted": false
   
   }


How do I get it to post the school ID as 1 and not as NULL?
 
Bartender
Posts: 2061
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your code how you set up the relationship between the student and school?
 
Nathan Milota
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed @JsonIgnore to @JsonBackReference and it seemed to fix the problem for now.
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic