Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to insert(save) 2 entities with Bidirectional relationship in Spring Boot Controller?

 
Ranch Hand
Posts: 602
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts,

I am stuck at how to handle 2 entities(models) in the Controller of a Spring Boot web app.

This is my attempt so far :



I have googled but just can't find something relevant.

Hope someone can tell me the right way to do it.

Tks.
 
Rancher
Posts: 527
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first of all you capitalized a variable name which is a nono. Also, you don't have to use modelAttribute. If you  just name the properties in the html form after the properties of two different models then spring will automatically make them and insert them in the method parameters.

not sure how I would do two model attributes.
 
Ranch Hand
Posts: 240
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have answered your similar question in your another post.
Try and let us know if that works out.
 
It's a tiny ad only because the water is so cold.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic