title: java mapstruct 1.3.1 ignore property in a list for bi-directional DTO mapping
body: <p>I'm struggling with cycle dependency problem with MapStruct.
  I keep having a StackOverFlow error due to circular dependencies.
  To avoid it, I just need to exclude a property of a List. 
  I found this : <a href="https://github.com/mapstruct/mapstruct/issues/933" rel="nofollow noreferrer">https://github.com/mapstruct/mapstruct/issues/933</a>
  I deeply looked over the internet and I have been surprised that I couldn't find any full exemple showing a bi-directional DTO mapping with MapStruct (except using <code>@Context CycleAvoidingMappingContext</code>, not working to me).</p>
  
  <p><strong>[EDIT]: I found a workaround thanks to MapStruct chat, I add it to <code>EditorMapper</code></strong></p>
  
  <p>Here is my case, pretty common I guess :
  I have 2 DTOs referencing each other:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class BookDTO {
  
      private Long id;
  
      private String title;
  
          //... other properties
  
      //@JsonManagedReference --&gt; not necessary anymore
      private EditorDTO editor;
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>public class EditorDTO {
  
      private Long id;
      private String name;
  
          //...other properties
  
      //@JsonBackReference --&gt; not necessary anymore
      private List&lt; BookDTO &gt; bookList;
  }
  </code></pre>
  
  <p>And I need MapStruct to be able to exclude the property Editor from the BookList in Editor, and then avoid the infinite loop.
  Here is what I currently have as mappers:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Mapper
  public interface BookMapper {
  
      BookMapper INSTANCE = Mappers.getMapper( BookMapper.class );
  
      @Mapping( target = "editor.bookList", ignore = true)
      BookDTO toDTO( BookEntity bookEntity );
  
      @Named( "NoEditor" )
      @Mapping(target = "editor", ignore = true)
      BookDTO toDTONoEditor( BookEntity bookEntity );
  
      List&lt;BookDTO&gt; toDTOList( List&lt;BookEntity&gt; bookEntityList );
  
      @Named( "NoEditor" )
      @IterableMapping(qualifiedByName="NoEditor")
      List&lt;BookDTO&gt; toDTOListNoEditor( List&lt;BookEntity&gt; bookEntityList );
  
      @Mapping( target = "editor.bookList", ignore = true)
      BookEntity toEntity( BookDTO bookDTO );
  
      List&lt;BookEntity&gt; toEntityList( List&lt;BookDTO&gt; bookDTOList );
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Mapper(uses = BookMapper.class)
  public interface EditorMapper {
  
      EditorMapper INSTANCE = Mappers.getMapper( EditorMapper.class );
  
      @Named( "NoEditor" )
      @Mapping(target = "bookList", qualifiedByName = "NoEditor")
      EditorDTO toDTO( EditorEntity editorEntity );
  
      @Named( "NoEditor" )
      @IterableMapping(qualifiedByName="NoEditor")
      List&lt;EditorDTO&gt; toDTOList( List&lt; EditorEntity &gt; editorEntityList );
  
      EditorEntity toEntity( EditorDTO editorDTO );
  
      List&lt;EditorEntity&gt; toEntityList( List&lt; EditorDTO &gt; editorDTOList );
  }
  </code></pre>
  
  <p><strong>[EDIT]: it now works but it's not 100% clean (please see the answer I posted for more details)</strong></p>
  
  <p>I also tried this kind of method in mappers, but it didn't have any effect on my pb.</p>
  
  <pre class="lang-java prettyprint-override"><code>BookDTO toDTO( BookEntity bookEntity, @Context CycleAvoidingMappingContext context );
  </code></pre>
  
  <p>Does anyone know what I'm doing wrong? THANKS A LOT! :)</p>