【问题标题】:Cannot retrieve a set of super type object from SDN4无法从 SDN4 检索一组超类型对象
【发布时间】:2015-11-04 11:11:55
【问题描述】:

Neo4j 可以将超类型保存为标签之一的功能确实很棒,但是我无法按预期检索一组超类型。

超类叫做Service

@NodeEntity
public abstract class Service implements java.io.Serializable {...}

子类叫做HostingService

@NodeEntity
public class HostingService extends Service implements java.io.Serializable{

    @GraphId Long id;
        ....
}

还有一个类叫SystemCatalog来拥有一套Service

@NodeEntity
public class SystemCatalog implements java.io.Serializable{

     @GraphId Long id;
     .... 

     @Relationship(type="SERVICE", direction=Relationship.OUTGOING)
     private Set<Service> services = new HashSet<>();

}

保存测试方法顺利,neo4j浏览器显示HostingService同时保存了标签(Service和HostingService)

   @Test 
public void testSaveService(){

    SystemCatalog sys = new SystemCatalog();
    sys.setSystemName("Test Service");

    HostingService host = new HostingService();
    host.setCostCenter("Cost Center A");

    sys.getServices().add(host);

    Long id = systemCatalogRepository.save(sys).getId();
    System.out.println(id);

}

检索到的测试方法出错,返回的SystemCatalog根本没有任何服务

@Test
public void testGetService(){

    SystemCatalog sys2 = systemCatalogRepository.findOne(new Long(243));
    System.out.println(sys2);

}

【问题讨论】:

    标签: java neo4j spring-data-neo4j spring-data-neo4j-4


    【解决方案1】:

    这是一个错误,您的代码看起来不错。

    请关注https://jira.spring.io/browse/DATAGRAPH-735追踪。

    【讨论】:

    • 嗨卢安妮!你知道 spring-data-neo4j 3.3.2.RELEASE 中是否存在相同的错误。我面临着类似的issue
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多