title: Spring Data Rest projection does not work for single resources
body: <p>I have the following projection written for an entity class.</p>
  
  <pre><code>@Projection(name = "instituteProjection", types = { Institute.class })
  public interface InstituteProjection {
  
      String getOrganizationName();
  
      Address getRegisteredAddress();
  }
  </code></pre>
  
  <p>Now I am trying to apply this projection whenever I call the url  <code>http://localhost:8080/institutes/1?projection=instituteProjection</code>  which returns a single institute resource. The controller GET method implementation is as follows:</p>
  
  <pre><code>@RequestMapping(value = "institutes/{instituteId}", method = RequestMethod.GET,
          produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity&lt;?&gt; getInstitute(@PathVariable Long instituteId) {
      Institute institute = service.getInstitute(instituteId);
      return new ResponseEntity&lt;&gt;(institute, HttpStatus.OK);
  }
  </code></pre>
  
  <p>The problem is this does not return the institute projection. It returns the default repository json. </p>
  
  <p>The projection only works if I use the SDR generated controller instead of the custom rest controller I have implemented. </p>
  
  <p>So how do I apply the projection in the custom controller?</p>
  
  <p><strong>UPDATE 1</strong>
  Institute class</p>
  
  <pre><code>@Data
  @Entity
  public class Institute{
  
   private String organizationName;
  
      @OneToOne
      private Address registeredAddress;
  
      @OneToOne
      private Address mailingAddress;
  
  }
  </code></pre>
  
  <p>UPDATE 2</p>
  
  <p>Address class</p>
  
  <pre><code>    public class Address {
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="id")
      private long addressID;   
  
      @ManyToOne
      private Street street;
  
      @ManyToOne
      private Country country;
  
      private double latitude;
  
      private double longitude;
  
      @ManyToOne
      private City city;
  
  
  }
  </code></pre>