title: Want to include relationships in Spring REST API
body: <p>I am new in Spring.</p>
  
  <p>I have three entity <code>Invoice, Line and Product</code>.</p>
  
  <p>(1) If I call <code>GET /invoices</code> then I want output like,</p>
  
  <pre><code>{
      "invoices": [
          {
              "id": "101",
              "date": "2013-02-14"
          },
          {
              "id": "102",
              "date": "2013-02-18"
          }
      ]
  }
  </code></pre>
  
  <p>I have done this, I am able to do this but not able to include relations in the get request.</p>
  
  <p>(2) I want to GET call something like this which include relations.</p>
  
  <pre><code>GET /invoices?include=invoice.lines:embed,invoice_line.product:sideload
  </code></pre>
  
  <p>I want output like</p>
  
  <pre><code>{
      "invoices": [
          {
              "id": "101",
              "date": "2013-02-14",
              "lines": [
                  {
                      "id": "201",
                      "product_id": "301",
                      "amount": 100
                  },
                  {
                      "id": "201",
                      "product_id": "302",
                      "amount": 100
                  }
              ]
          },
          {
              "id": "102",
              "date": "2013-02-18",
              "lines": [
                  {
                      "id": "203",
                      "product_id": "301",
                      "amount": 100
                  }
              ]
          }
      ],
      "products": [
          {
              "id": "301",
              "name": "Ice Cream"
          },
          {
              "id": "302",
              "name": "Waffles"
          }
      ]
  }
  </code></pre>
  
  <p>I got stuck in (2) include relationship, I want to achieve something like this 
  need help.
  Thanks in advance.</p>