如何从Neo4j检索地图数据?

时间:2019-07-21 16:41:05

标签: spring-boot neo4j spring-data-neo4j neo4j-ogm

我正在使用Sprintboot + Neo4j应用程序,我的Entity类如下所示

@MockBean

在Neo4j中存储的数据看起来像这样

import java.io.Serializable;
import java.util.Map;

import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Properties;
import org.neo4j.ogm.annotation.Property;

@NodeEntity(label = "com.model.role.test")
public class Role implements Serializable {

    private static final long serialVersionUID = -8010543109475083169L;

    private String role = null;

    private String description = null;


    @Properties
    private Map<String, String> labels;

    @Id
    @GeneratedValue
    private Long id;

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Map<String, String> getLabels() {
        return labels;
    }

    public void setLabels(Map<String, String> labels) {
        this.labels = labels;
    }

}

但是当我借助SpringBoot + Neo4j检索数据时

<id>:14972 description: Narayan labels.LABEL1Access: R labels.LABEL1Labe lname: com.model.Equipment labels.LABEL1Match1subType: chassis labels.LABEL1Match1type: chassis labels.LABEL2Access: CWRD labels.LABEL2Labelname: com.model.Service labels.LABEL2Match2subType: chassis123 labels.LABEL2Match2type: chassis123labels.LABEL3Access: RW labels.LABEL3Labelname: com.model.Test labels.LABEL3Match3subType: path labels.LABEL3Match3type: path role: Narayan

返回记录如下

Role roleObject = roleRepository.findByRole(role);

但是存储的数据是{LABEL#com={model={service#Match#type=chassis123, equipment#Access=R, service#Match#subType=chassis123, equipment#Match#subType=chassis, service=com.model.Service, equipment=com.model.Equipment, equipment#Match#type=chassis, service#Access=CWRD}}} 格式,如何获得相同的数据返回值而不是我得到的数据?

0 个答案:

没有答案