title: Neo4j SDN4 OGM AmbiguousBaseClassException
body: <p>I am running into an issue wherein some of my Neo4J queries like the one below ends up in an OGM AmbiguousBaseClassException while others don't. For example findByTitle for the movie "The Score" throws an exception but "The Matrix" does not. My graph is populated by the Movie Database found at <a href="https://neo4j.com/developer/example-data/" rel="nofollow noreferrer">https://neo4j.com/developer/example-data/</a></p>
  
  <p>I am unable to find an explanation to the above observation and I hope someone can help.</p>
  
  <p>curl <a href="http://localhost:8080/movies/search/findByTitle?title=The%20Score" rel="nofollow noreferrer">http://localhost:8080/movies/search/findByTitle?title=The%20Score</a></p>
  
  <p>Neo4j Server: 3.1.0</p>
  
  <p>Spring-data-neo4j:4.1.1</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.neo4j.ogm.exception.MappingException: Error mapping GraphModel to instance of com.knowledgeGraph.kgClient.domain.Movie
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
  
  Caused by: org.neo4j.ogm.exception.AmbiguousBaseClassException: Multiple classes found in type hierarchy that map to: [Person, Actor, Director]
  at org.neo4j.ogm.MetaData.resolve(MetaData.java:174) ~[neo4j-ogm-core-2.0.1.jar:na]
  at org.neo4j.ogm.annotations.EntityFactory.resolve(EntityFactory.java:121) ~[neo4j-ogm-core-2.0.1.jar:na]
  at org.neo4j.ogm.annotations.EntityFactory.instantiateObjectFromTaxa(EntityFactory.java:105) ~[neo4j-ogm-core-2.0.1.jar:na]
  at org.neo4j.ogm.annotations.EntityFactory.newObject(EntityFactory.java:61) ~[neo4j-ogm-core-2.0.1.jar:na]
  </code></pre>
  
  <p>Domain Objects:</p>
  
  <p>Movie Class:</p>
  
  <pre><code>import static org.neo4j.graphdb.Direction.INCOMING;
  import org.neo4j.ogm.annotation.GraphId;
  import org.neo4j.ogm.annotation.NodeEntity;
  import org.neo4j.ogm.annotation.Relationship;
  
  import com.fasterxml.jackson.annotation.JsonIdentityInfo;
  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  import com.voodoodyne.jackson.jsog.JSOGGenerator;
  
  @JsonIdentityInfo(generator=JSOGGenerator.class)
  @NodeEntity
  @JsonIgnoreProperties(ignoreUnknown = true)
  public class Movie {
  
  @GraphId Long nodeId;
  String id;
  String title;
  String description;
  
  @Relationship(type="DIRECTED", direction = Relationship.INCOMING)
  List&lt;Person&gt; directors;
  
  @Relationship(type="ACTS_IN", direction = Relationship.INCOMING)
  List&lt;Person&gt; actors;
  
  private String language;
  private String imdbId;
  private String tagline;
  private String releaseDate;
  private Integer runtime;
  private String homepage;
  private String trailer;
  private String genre;
  private String studio;
  private Integer version;
  private String lastModified;
  private String imageUrl;
  
  public Movie() { }
  
  public String getId() {
      return id;
  }
  public void setId(String id) {
      this.id = id;
  }
  
  /*Remaining Set's and Get's*/
  
  }
  </code></pre>
  
  <p>Person Class:</p>
  
  <pre><code>import org.neo4j.ogm.annotation.GraphId;
  import org.neo4j.ogm.annotation.NodeEntity;
  import com.fasterxml.jackson.annotation.JsonSubTypes;
  
  @NodeEntity
  @JsonSubTypes({
  @JsonSubTypes.Type(value = Actor.class, name = "actor"),
  @JsonSubTypes.Type(value = Director.class, name = "director")
  })
  
  public class Person {
  
      @GraphId Long nodeId;
      String id;
      String name;
      private String birthday;
      private String birthplace;
      private String biography;
      private Integer version;
      private String lastModified;
      private String profileImageUrl;
  
      public Person () {}
  
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
  
      /*Remaining Set's and Get's*/
  
  }
  </code></pre>
  
  <p>Director Class:</p>
  
  <pre><code>@NodeEntity
  public class Director extends Person{
  
  @GraphId
  Long id;
  
  public Director() {
  }
  
  @Relationship(type="DIRECTED", direction = Relationship.OUTGOING)
  private List&lt;Movie&gt; directedMovies = new ArrayList&lt;Movie&gt;();
  
  public List&lt;Movie&gt; getDirectedMovies() {
      return directedMovies;
  }
  
  public void setDirectedMovies(List&lt;Movie&gt; directedMovies) {
      this.directedMovies = directedMovies;
  }
  
  }
  </code></pre>
  
  <p>Actor Class:</p>
  
  <pre><code>@NodeEntity
  public class Actor extends Person {
  
  @GraphId
  Long id;
  
  public Actor() {
  }
  
  @Relationship(type="ACTS_IN", direction = Relationship.OUTGOING)
  private List&lt;Movie&gt; actedMovies = new ArrayList&lt;Movie&gt;();
  
  public List&lt;Movie&gt; getMovies() {
      return actedMovies;
  }
  
  public void setMovies(List&lt;Movie&gt; movies) {
      this.actedMovies = movies;
  }
  }
  </code></pre>
  
  <p>Repositories:</p>
  
  <pre><code>public interface ActorRepository extends GraphRepository&lt;Actor&gt;{
  
      @Query("MATCH (a:Actor) -[:ACTS_IN]-&gt; (m:Movie {`title`:{title}}) return a")
      Collection&lt;Actor&gt; findActorsOfMovie(@Param("title") String title);
  }
  
  
  public interface DirectorRepository extends GraphRepository&lt;Director&gt;{
  
      @Query("MATCH (d:Director) -[:DIRECTED]-&gt; (m:Movie {`title`:{title}}) return d")
      Collection&lt;Director&gt; findDirectorOfMovie(@Param("title") String title);
  
  }
  
  public interface MovieRepository extends GraphRepository&lt;Movie&gt;{
  
      Movie findByTitle(@Param("title") String title);
  
      @Query("MATCH (m:Movie) WHERE m.title =~ ('(?i).*'+{title}+'.*') RETURN m")
      Collection&lt;Movie&gt; findByTitleContaining(@Param("title") String title);
  }
  
  public interface PersonRepository extends GraphRepository&lt;Person&gt;{
  
      @Query("MATCH (a:Person) -[:ACTS_IN]-&gt; (m:Movie {`title`:{title}}) return a")
      Set&lt;Person&gt; findActorsOfMovie(@Param("title") String title);
  
      @Query("MATCH (d:Person) -[:DIRECTED]-&gt; (m:Movie {`title`:{title}}) return d")
      Set&lt;Person&gt; findDirectorOfMovie(@Param("title") String title);
  }
  </code></pre>