title: Rest service in SpringBoot expects a nested object in JSON from GET request
body: <p>I am using SpringBoot. I have two entities, Users and Role. For each user record I want to assign a role.</p>
  <p>In my entities I already have the relationship and the database is built as I want.</p>
  <p>When I see the service, it asks me for the Role object when I want to save the user. Am I right in wanting to create the User record? Or with @AutoWired can I add in my repository class the instance of Role and search it by id?</p>
  <p>What do you recommend? I am still newbie with Rest services.</p>
  <p>As an example, when invoking the create user service, the JSON it expects is the following:</p>
  <pre class="lang-json prettyprint-override"><code>{ 
    &quot;id&quot;: 1,
    &quot;usuario&quot;: &quot;JUANITO&quot;,
    &quot;password&quot;: &quot;*********&quot;,
    &quot;correo&quot;: &quot;algo@algo.com&quot;,
    &quot;estado&quot;: &quot;ACTIVO&quot;,
    &quot;fecha&quot;: 12125368254,
    &quot;rol&quot;: {
      &quot;descripcion&quot;: &quot;ADMIN&quot;,
      &quot;estado&quot;: &quot;ACTIVO&quot;,
      &quot;id&quot;: 1
    }
  }
  </code></pre>
  <p>I wish it was something similar to this:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;id&quot;: 1,
    &quot;usuario&quot;: &quot;JUANITO&quot;,
    &quot;password&quot;: &quot;*********&quot;,
    &quot;correo&quot;: &quot;algo@algo.com&quot;,
    &quot;estado&quot;: &quot;ACTIVO&quot;,
    &quot;fecha&quot;: 12125368254,
    &quot;rol&quot;: 1
  }
  </code></pre>
  <p>That is, I do NOT want to create a new Role object, but use an existing one and assign it to my User record.</p>