title: DTO and Entities mapping
body: <p>I am building a Spring Rest Application, I need help with DTO's and parsing a result to a endpoint</p>
  <ul>
  <li><p>This is json that I return at the moment to the endpoint:</p>
  <pre><code>{
    &quot;id&quot;: 1,
    &quot;name&quot;: &quot;Ella - IPA Is Dead&quot;,
    &quot;description&quot;: &quot;2015 IPA is Dead Series. Supremely floral, this hugely under-rated hop is related to Galaxy and was first cultivated in the Australian state of Victoria.&quot;,
    &quot;method&quot;: {
        &quot;mash_temp&quot;: [
         {
             &quot;temp&quot;: {
                 &quot;value&quot;: 65
             }
         }
    ]
   }
  }
  </code></pre>
  </li>
  </ul>
  <p>I don't want to return &quot;method&quot; from this json, I just need &quot;id&quot;, &quot;name&quot;, &quot;description&quot;, &quot;mash_temp&quot; - so it should look like this:</p>
  <pre><code>{
    &quot;id&quot;: 1,
    &quot;name&quot;: &quot;Ella - IPA Is Dead&quot;,
    &quot;description&quot;: &quot;2015 IPA is Dead Series. Supremely floral, this hugely under-rated hop is related to Galaxy and was first cultivated in the Australian state of Victoria. Initially given the same name as a certain Eurolager, their lawyers got involved and the St- prefix was dropped. Ella displays subtle notes of spice, but is fundamentally a truly floral bouquet, redolent of the Southern Hemisphere.&quot;,
    &quot;mash_temp&quot;: [
     {
        &quot;temp&quot;: {
           &quot;value&quot;: 65
           }
        }
    ]
  }
  </code></pre>
  <p>Those are the entities that I am using now:</p>
  <ul>
  <li><p>Beer Entity:</p>
  <pre><code>@Entity
  public class Beer implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;beer_id&quot;, unique = true, nullable = false)
      private Integer id;
  
      @Column(name = &quot;name&quot;, nullable = false)
      private String name;
  
      @JsonProperty(&quot;description&quot;)
      @Column(name = &quot;description&quot;, nullable = false, columnDefinition = &quot;TEXT&quot;)
      private String description;
  
      @JsonProperty(&quot;method&quot;)
      @OneToOne(cascade = CascadeType.ALL)
      private Method method;
  }
  </code></pre>
  </li>
  <li><p>Method Entity:</p>
  <pre><code>@Entity
  public class Method implements Serializable
  {
  
       @JsonIgnore(value = true)
       @Id
       @GeneratedValue(strategy = GenerationType.IDENTITY)
       private Integer id;
  
       @JsonProperty(&quot;mash_temp&quot;)
       @OneToMany(cascade = CascadeType.ALL)
       @JoinColumn(name = &quot;mash_temp&quot;)
       private List&lt;MashTemp&gt; mash_temp = new ArrayList&lt;&gt;();
  }
  </code></pre>
  </li>
  <li><p>MashTemp Entity:</p>
  <pre><code>@Entity
  public class MashTemp implements Serializable
  {
  
      @JsonIgnore(value = true)
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      @OneToOne(cascade = CascadeType.ALL)
      private Temp temp;
  
      @ManyToOne
      private Method method;
  }
  </code></pre>
  </li>
  <li><p>Temp Entity:</p>
  <pre><code>@Entity
  public class Temp implements Serializable
  {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      private Integer value;
  
      @JsonIgnore(value = true)
      private String unit;
  
      @OneToOne
      private MashTemp mashTemp;
  }
  </code></pre>
  </li>
  </ul>
  <p>Does anyone know how to create DTO's from this Entities but without &quot;method&quot; field?</p>
  <ul>
  <li><p>Also this is my Controller:</p>
  <pre><code>@GetMapping(&quot;/beers&quot;)
  public ResponseEntity&lt;Set&lt;Beer&gt;&gt; getAllBeers()
  {
      return new ResponseEntity&lt;&gt;(beerService.getAllBeers(), HttpStatus.OK);
  }
  
  @GetMapping(&quot;/beers/{id}&quot;)
  public ResponseEntity&lt;Beer&gt; getById(@PathVariable Integer id) {
      Beer beer = beerService.findById(id);
  
      return new ResponseEntity&lt;&gt;(beer, HttpStatus.OK);
  }
  </code></pre>
  </li>
  </ul>