With Spring data mongodb I have a couple of entities Person and Dog. Linked with DBRef, but pet property in Person can have multiple implementations and can be linked to different collections.
@Document
public class Person {
@Id
private String id;
private String name;
@DBRef(lazy = true)
private Pet pet;
}
public interface Pet {
public String getId();
public void setId(String id);
public String getName();
public void setName(String name);
}
@Document
public class Dog implements Pet {
@Id
private String id;
private String name;
}
Now when I try to check, it always returns me false. basically underlying lazyloading proxy is not implementing the target class. anyway to ensure that lazy loading proxy implements target class.
person.getPet() instanceof Dog