1
직원 목록을 저장하는 MongoDB 엔티티가 있다고 가정 해 봅니다.Morphia를 사용하는 MongoDB의 계층 적 객체 매핑
@Entitiy
public class EmployeeList{
@Embedded
List<Employee> employeeList;
}
직원은 일부 속성을 가진 추상 클래스입니다. 다른 직원의 유형이있다
public abstract class Employee{
String name;
String emailId;
}
- 개발자, 디자이너, HumanResource
class Developer extends Employee{
String githubProfile;
}
class Designer extends Employee{
String portfolio;
}
class HumanResource extends Employee{
String department;
}
는 몽고 개발자, 디자이너, humanResource 사람들의 목록이 포함되어있는 경우, 모르핀은 해당 클래스에 매핑 할 수 있습니까? DB를 다음 데이터가있는 경우 예를 들어, -이 컬렉션은 EmployeeList
엔티티에 모르핀에 의해 매핑되는
[{'name':'p1', 'emailId':'[email protected]", 'portfolio':'http://abc.co'},
{'name':'p2', 'emailId':'[email protected]", 'department':'finance'},
{'name':'p3', 'emailId':'[email protected]", 'githubProfile':'http://github.com/p3'}]
을, 어떻게 그들이 해당 클래스에 매핑되어 있는지 확인합니까?
예! 이 작품! 아이디어에 감사드립니다! :) – shiladitya