title: Spring Data Rest Ambiguous Association Exception
body: <p>The newly added <code>LinkCollectingAssociationHandler</code> is throwing a <code>MappingException</code> due to an ambiguous association in my domain class.</p>
  
  <p>The links array looks like this:</p>
  
  <p><code>[&lt;http://localhost:8080/rooms/2/roomGroups&gt;;rel="roomGroups", &lt;http://localhost:8080/rooms/2/userGroup&gt;;rel="userGroup", &lt;http://localhost:8080/rooms/2/room&gt;;rel="room", &lt;http://localhost:8080/rooms/2/originatingConferences&gt;;rel="originatingConferences", &lt;http://localhost:8080/rooms/2/user&gt;;rel="user"]</code></p>
  
  <p>And it is trying to add another 'room' relation when it throws the exception.</p>
  
  <p>The issue is that it seems to be adding links to relations which I have explicitly marked with <code>@RestResource(exported = false)</code></p>
  
  <p>Here is an example of a relation which I believe is causing this issue:</p>
  
  <pre><code>@JsonIgnore
  @RestResource(exported = false)
  @OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.room", cascade = {CascadeType.REMOVE})
  private Set&lt;RoomsByUserAccessView&gt; usersThatCanDisplay = new HashSet&lt;&gt;(); 
  </code></pre>
  
  <p>The type <code>RoomsByUserAccessView</code> has an embedded id made up of a <code>Room</code> and a <code>User</code>.</p>
  
  <p>I have also annotated the embedded id property with:</p>
  
  <pre><code>@JsonIgnore
  @RestResource(exported = false)
  private RoomsByUserAccessViewId pk = new RoomsByUserAccessViewId();
  </code></pre>
  
  <p>and its properties like this:</p>
  
  <pre><code>@JsonIgnore
  @RestResource(exported = false)
  private Room room;
  
  @JsonIgnore
  @RestResource(exported = false)
  private User userWithAccess;
  
  public RoomsByUserAccessViewId() {
      //
  }
  </code></pre>
  
  <p>How can I get it to ignore these relations properly when serializing to JSON?</p>
  
  <p>My code was working prior to DATAREST-262 (<a href="https://github.com/spring-projects/spring-data-rest/commit/1d53e84cae3d09b09c4b5a9a4caf438701527550">https://github.com/spring-projects/spring-data-rest/commit/1d53e84cae3d09b09c4b5a9a4caf438701527550</a>)</p>
  
  <p>The full error message returned when I try to visit the rooms/ endpoint is as follows:</p>
  
  <p><code>{
  timestamp: "2014-03-17T13:38:05.481-0500"
  error: "Internal Server Error"
  status: 500
  exception: "org.springframework.http.converter.HttpMessageNotWritableException"
  message: "Could not write JSON: Detected multiple association links with same relation type! Disambiguate association @com.fasterxml.jackson.annotation.JsonIgnore(value=true) @javax.persistence.ManyToOne(fetch=EAGER, cascade=[], optional=true, targetEntity=void) @org.springframework.data.rest.core.annotation.RestResource(description=@org.springframework.data.rest.core.annotation.Description(value=), path=, exported=false, rel=) private com.renovo.schedulerapi.domain.Room com.renovo.schedulerapi.domain.RoomsByUserAccessViewId.room using @RestResource! (through reference chain: org.springframework.hateoas.PagedResources["content"]-&gt;java.util.UnmodifiableCollection[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Detected multiple association links with same relation type! Disambiguate association @com.fasterxml.jackson.annotation.JsonIgnore(value=true) @javax.persistence.ManyToOne(fetch=EAGER, cascade=[], optional=true, targetEntity=void) @org.springframework.data.rest.core.annotation.RestResource(description=@org.springframework.data.rest.core.annotation.Description(value=), path=, exported=false, rel=) private com.renovo.schedulerapi.domain.Room com.renovo.schedulerapi.domain.RoomsByUserAccessViewId.room using @RestResource! (through reference chain: org.springframework.hateoas.PagedResources["content"]-&gt;java.util.UnmodifiableCollection[0])"
  }</code></p>