title: Spring HATEOAS & HAL: Change array name in _embedded
body: <p>I'm trying to build a HAL-compliant REST API with Spring HATEOAS.</p>
  
  <p>After some fiddling I managed to get to work <em>mostly</em> like expected.
  The (sample) output looks like this right now:</p>
  
  <pre><code>{
      "_links": {
          "self": {
              "href": "http://localhost:8080/sybil/configuration/bricks"
          }
      },
      "_embedded": {
          "brickDomainList": [
              {
                  "hostname": "localhost",
                  "port": 4223,
                  "_links": {
                      "self": {
                          "href": "http://localhost:8080/sybil/configuration/bricks/localhost"
                      }
                  }
              },
              {
                  "hostname": "synerforge001",
                  "port": 4223,
                  "_links": {
                      "self": {
                          "href": "http://localhost:8080/sybil/configuration/bricks/synerforge001"
                      }
                  }
              }
          ]
      }
  }
  </code></pre>
  
  <p>I don't like the "brickDomainList" array's name. It should say "bricks", ideally. How can I change it?  </p>
  
  <p>Here's the controller that produces the output:</p>
  
  <pre><code>@RestController
  @RequestMapping("/configuration/bricks")
  public class ConfigurationBricksController {
  
      private BrickRepository brickRepository;
      private GraphDatabaseService graphDatabaseService;
  
      @Autowired
      public ConfigurationBricksController(BrickRepository brickRepository, GraphDatabaseService graphDatabaseService) {
  
          this.brickRepository = brickRepository;
          this.graphDatabaseService = graphDatabaseService;
      }
  
      @ResponseBody
      @RequestMapping(method = RequestMethod.GET, produces = "application/hal+json")
      public Resources&lt;BrickResource&gt; bricks() {
  
          List&lt;BrickDomain&gt; bricks;
          List&lt;BrickResource&gt; resources = new ArrayList&lt;&gt;();
          List&lt;Link&gt; links = new ArrayList&lt;&gt;();
  
          Link self = linkTo(ConfigurationBricksController.class).withSelfRel();
          links.add(self);
  
          try(Transaction tx = graphDatabaseService.beginTx()) { // begin transaction
  
              // get all Bricks from database and cast them into a list so that they're actually fetched
              bricks = new ArrayList&lt;&gt;(IteratorUtil.asCollection(brickRepository.findAll()));
  
              // end transaction
              tx.success();
          }
  
          for (BrickDomain brick : bricks) {
              self = linkTo(methodOn(ConfigurationBricksController.class).brick(brick.getHostname())).withSelfRel();
  
              BrickResource resource = new BrickResource(brick, self);
  
              resources.add(resource);
          }
  
          return new Resources&lt;&gt;(resources, links);
      }
  }
  </code></pre>
  
  <p>Is there some Annotation or something I can add to change the array's name?</p>
  
  <p>If you want/need to look at the BrickResource class or the Repositories or something look here: <a href="https://github.com/ttheuer/sybil/tree/mvctest/src/main/java/org/synyx/sybil" rel="noreferrer">https://github.com/ttheuer/sybil/tree/mvctest/src/main/java/org/synyx/sybil</a></p>
  
  <p>The BrickResource is in api/resources/, the repository is in database/, and the BrickDomain in domain/.</p>
  
  <p>Thanks!</p>