public class Company implements Serializable {
@RelatedTo(type = "REPORT_TO", direction = Direction.INCOMING)
private List<Department> departments;
@RelatedTo(type = "REPORT_TO", direction = Direction.INCOMING)
private List<Company> subCompanies;
In class Company, there are two list with different labels (Department and Company),
but when I use neo4jTemplate.fetch(company.getSubCompanies()), the result is the total of departments and subCompanies. It seems spring-neo4j search results by relationship, and search all the label, not the specific one
So why the departments will return ? And the amazing thing is that @Override public List<Company> getSubCompaniesByCompanyId(Long companyId) { Company company = companyRepository.findOne(companyId); return neo4jTemplate.fetch(company.getSubCompanies()); }
@Override public List<Company> getSubCompaniesByCompanyId(Long companyId) { Company company = companyRepository.findOne(companyId); return neo4jTemplate.fetch(company.getSubCompanies()); }
the chrome console will get the Department bean, how can it convert to Company.......
Add the beans to see the amazing and the console result
The properties has "departmentType", which is the property of Department, but now in the bean of Company..... And I've seen in java, the bean in List is Department!!!
Did you try to use the annotation attribute: enforceTargetType=true
which should limit the types to the one given in the target. (You might need to use elementClass=Department.class
as well, can't remember exactly)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.