Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 未与queryForObject映射的简单关系_Neo4j_Neo4j Ogm - Fatal编程技术网

Neo4j 未与queryForObject映射的简单关系

Neo4j 未与queryForObject映射的简单关系,neo4j,neo4j-ogm,Neo4j,Neo4j Ogm,我有一个问题。我使用的是neo4j ogm快照1.5。 我有以下课程: @NodeEntity public abstract class Entity { @GraphId protected Long id; @Expose protected String code = null; @Override public boolean equals(Object o) { if (this == o)

我有一个问题。我使用的是neo4j ogm快照1.5。 我有以下课程:

@NodeEntity
public abstract class Entity {
    @GraphId
    protected Long id;

    @Expose
    protected String code = null;

    @Override
    public boolean equals(Object o) {
        if (this == o) 
            return true;

        if (o == null || id == null || getClass() != o.getClass()) 
            return false;

        Entity entity = (Entity) o;

        if (!id.equals(entity.id)) 
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        return (id == null) ? -1 : id.hashCode();
    }

    public Long getId(){
        return id;
    }

    public void setId(Long neo4jId){
        this.id = neo4jId;
    }

    public String getCode(){
        return code;
    }

    public void setCode(String code){
        this.code = code;
    }
}



public class PropertyGroup extends Entity{

    @Expose
    private String name;

    public PropertyGroup(){

    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}


public class User  extends Entity {
    private Long registration_date;

    private Long last_login_date;

    private Boolean is_admin = false;

    private String push_dev;

    private String push_id;

    private Boolean push_enabled = false;

    @Expose
    private String avatar;
    @Expose
    private String avatarUrl;
    @Expose
    private String name;
    @Expose
    private volatile String password;
    @Expose
    private int likes = 0;
    @Expose
    private int questionCount = 0;
    @Expose
    private int followersCount = 0;
    @Expose
    private boolean isFollowing = false;


//  public Set<UserPropertyRelation> properties;

//  @Relationship(type = ModelRelType.ANSWERED)
//  public Set<UserAnsweredRelation> userAnswers;
//
//  @Relationship(type = ModelRelType.LIKES)
//  private Set<LikesQuestionRelation> questionsLiked;



    @Expose
    @Relationship(type = ModelRelType.HAS_PROPERTY)
    private Set<PropertyGroup> properties;

//  private Profile userProfile;

//  private List<Fact> facts;
//  @Expose
//  @Relationship(type = ModelRelType.OWNS)
//  private List<Question> questions;

    public User(){
//      this.properties = new LinkedHashSet<UserPropertyRelation>();
//      this.userAnswers = new LinkedHashSet<UserAnsweredRelation>();
//      this.userProperties = new HashSet<PropertyGroup>();
//      this.setFacts(new ArrayList<Fact>());
        this.properties = new HashSet<PropertyGroup>();
    }

    public User(long regDate, long lastLoginDate, boolean isAdmin, 
            String pushDev, String pushId, boolean pushEnabled){
        this();
        this.registration_date = regDate;
        this.last_login_date = lastLoginDate;
        this.is_admin = isAdmin;
        this.push_dev = pushDev;
        this.push_id = pushId;
        this.push_enabled = pushEnabled;    
    }

//  public void addUserAnsweredRelation(UserAnsweredRelation answer){
//      answer.setStartNode(this);
//      this.userAnswers.add(answer);
//  }
//  
//  public Set<UserAnsweredRelation> getUserAnsweredRelations() {
//      return this.userAnswers;
//  }

//  public void setUserAnsweredRelations(Set<UserAnsweredRelation> userAnswers){
//      for(UserAnsweredRelation a : userAnswers){
//          a.setStartNode(this);
//      }
//      
//      this.userAnswers = userAnswers;
//  }
//  
//  public void addUserPropertyRelation(UserPropertyRelation rel){
//      rel.setUser(this);
//      properties.add(rel);
//  }
//  
//  public void setUserPropertyRelations(Set<UserPropertyRelation> properties){
//      for(UserPropertyRelation r: properties){
//          r.setUser(this);
//      }
//      
//      this.properties = properties;
//  }

//  public Set<UserPropertyRelation> getUserPropertyRelations(){
//      return this.properties;
//  }

    public long getRegistrationDate() {
        return registration_date;
    }

    public void setRegistrationDate(long registrationDate) {
        this.registration_date = registrationDate;
    }

    public long getLastLoginDate() {
        return last_login_date;
    }

    public void setLastLoginDate(long lastLoginDate) {
        this.last_login_date = lastLoginDate;
    }

    public boolean isAdmin() {
        return is_admin;
    }

    public void setAdmin(boolean isAdmin) {
        this.is_admin = isAdmin;
    }

    public String getPushDev() {
        return push_dev;
    }

    public void setPushDev(String pushDev) {
        this.push_dev = pushDev;
    }

    public String getPushId() {
        return push_id;
    }

    public void setPushId(String pushId) {
        this.push_id = pushId;
    }

    public boolean isPushEnabled() {
        return push_enabled;
    }

    public void setPushEnabled(boolean pushEnabled) {
        this.push_enabled = pushEnabled;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<PropertyGroup> getProperties() {
        return properties;
    }

    public void setProperties(Set<PropertyGroup> properties) {
        this.properties = properties;
    }

//  public Profile getUserProfile() {
//      return userProfile;
//  }
//
//  public void setUserProfile(Profile userProfile) {
//      this.userProfile = userProfile;
//  }

//  public Set<LikesQuestionRelation> getQuestionsLiked() {
//      return questionsLiked;
//  }
//
//  public void setQuestionsLiked(Set<LikesQuestionRelation> likes) {
//      this.questionsLiked = likes;
//  }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

//  public List<Fact> getFacts() {
//      return facts;
//  }
//
//  public void setFacts(List<Fact> facts) {
//      this.facts = facts;
//  }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public int getLikes() {
        return likes;
    }

    public void setLikes(int likes) {
        this.likes = likes;
    }

    public int getQuestionCount() {
        return questionCount;
    }

    public void setQuestionCount(int questionCount) {
        this.questionCount = questionCount;
    }

    public int getFollowersCount() {
        return followersCount;
    }

    public void setFollowersCount(int followersCount) {
        this.followersCount = followersCount;
    }

    public boolean isFollowing() {
        return isFollowing;
    }

    public void setFollowing(boolean isFollowing) {
        this.isFollowing = isFollowing;
    }

//  public List<Question> getQuestions() {
//      return questions;
//  }
//
//  public void setQuestions(List<Question> questions) {
//      this.questions = questions;
//  }
@NodeEntity
公共抽象类实体{
@格拉希德
保护长id;
@暴露
受保护的字符串代码=null;
@凌驾
公共布尔等于(对象o){
if(this==o)
返回true;
如果(o==null | | id==null | | getClass()!=o.getClass())
返回false;
实体=(实体)o;
如果(!id.equals(entity.id))
返回false;
返回true;
}
@凌驾
公共int hashCode(){
返回值(id==null)?-1:id.hashCode();
}
公共长getId(){
返回id;
}
公共无效设置ID(长neo4jId){
this.id=neo4jId;
}
公共字符串getCode(){
返回码;
}
公共无效设置码(字符串码){
this.code=代码;
}
}
公共类PropertyGroup扩展实体{
@暴露
私有字符串名称;
公共属性组(){
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
}
公共类用户扩展实体{
私人长注册日期;
私人长最后登录日期;
私有布尔值为_admin=false;
私有字符串推送开发;
私有字符串push_id;
私有布尔push_enabled=false;
@暴露
私有字符串化身;
@暴露
私有字符串;
@暴露
私有字符串名称;
@暴露
私有易失性字符串密码;
@暴露
私有int=0;
@暴露
私人内部问题计数=0;
@暴露
私有int followersCount=0;
@暴露
私有布尔值isFollowing=false;
//公共集合属性;
//@Relationship(type=ModelRelType.responsed)
//公共设置用户答案;
//
//@Relationship(type=ModelRelType.LIKES)
//私人设置问题;
@暴露
@关系(type=ModelRelType.HAS\u属性)
私有集属性;
//私有配置文件userProfile;
//私人清单事实;
//@暴露
//@Relationship(type=ModelRelType.OWNS)
//私人名单问题;
公共用户(){
//this.properties=new LinkedHashSet();
//this.userAnswers=new LinkedHashSet();
//this.userProperties=new HashSet();
//this.setFacts(新的ArrayList());
this.properties=new HashSet();
}
公共用户(长regDate、长lastLoginDate、布尔isAdmin、,
字符串pushDev、字符串pushId、布尔pushEnabled){
这个();
this.registration_date=regDate;
this.last\u login\u date=lastloginandate;
this.is_admin=isAdmin;
this.push_dev=pushDev;
this.push_id=pushId;
this.push_enabled=pushEnabled;
}
//public void addUserAnsweredRelation(UserAnsweredRelation应答){
//答案:setStartNode(本);
//this.userAnswers.add(answer);
//  }
//  
//公共集getUserAnsweredRelations(){
//返回这个.userAnswers;
//  }
//public void setUserAnsweredRelations(Set userAnswers){
//for(用户应答关系a:userAnswers){
//a.设置开始节点(本节点);
//      }
//      
//this.userAnswers=userAnswers;
//  }
//  
//public void addUserPropertyRelation(UserPropertyRelation){
//相对设置用户(本);
//添加(rel);
//  }
//  
//公共void setUserPropertyRelations(集合属性){
//for(UserPropertyRelation r:properties){
//r.setUser(本);
//      }
//      
//这个。属性=属性;
//  }
//公共集getUserPropertyRelations(){
//返回此文件。属性;
//  }
公共长getRegistrationDate(){
返回注册日期;
}
公共无效设置注册日期(长注册日期){
this.registration_date=注册日期;
}
公共长getLastLoginDate(){
返回上次登录日期;
}
公共无效setLastLoginDate(长lastLoginDate){
this.last\u login\u date=lastloginandate;
}
公共布尔值isAdmin(){
返回是_admin;
}
公共void setAdmin(布尔值isAdmin){
this.is_admin=isAdmin;
}
公共字符串getPushDev(){
返回推送开发;
}
公共void setPushDev(字符串pushDev){
this.push_dev=pushDev;
}
公共字符串getPushId(){
返回推送标识;
}
公共void setPushId(字符串pushId){
this.push_id=pushId;
}
公共布尔值isPushEnabled(){
返回push_已启用;
}
public void setPushEnabled(布尔pushEnabled){
this.push_enabled=pushEnabled;
}
公共字符串getAvatar(){
返回化身;
}
公共虚拟化身(字符串化身){
this.avatar=化身;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}
公共集getProperties(){
归还财产;
}
公共void集合属性(集合属性){
这个。属性=属性;
}
//公共配置文件getUserProfile(){
//返回userProfile;
//  }
//
//public void setUserProfile(Profile userProfile){
//this.userProfile=userProfile;
//  }
//公共集getQuestionsLiked(){
//回答问题;
//  }
//
//公共无效设置问题已删除(设置类似项){
//this.questionsLiked=喜欢;
//  }
公共字符串getPassword(){
返回密码;
}
public void setPassword(字符串密码){
this.password=密码;
}
//公共列表getFacts(){
//返回事实;
//  }
//
//公共事实(列出事实){
//事实=事实;
//  }
公共字符串getAvatarUrl(){
返回avatarUrl;
}
公共无效设置avatarUrl(字符串avatarUrl){
this.avatarUrl=avatarUrl;
}
公共int getLikes(){
回报喜欢;
}
公共void setLikes(int likes){
th
SessionFactory sessionFactory = new SessionFactory(modelsPackageName);
        Session session = sessionFactory.openSession(url);

        String cypher = "MATCH (u:User {code: {CODE}})-[h:HAS_PROPERTY]->(pg:PropertyGroup) " +
                "RETURN u, h, pg";

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("CODE", "fc48b19ba6f8427a03d6e5990bcef99a28f55592b80fe38731cf805ed188cabf");
//      System.out.println(Util.mergeParamsWithCypher(cypher, params));
        User u = session.queryForObject(User.class, cypher, params);
 <dependency>
     <groupId>org.neo4j</groupId>
     <artifactId>neo4j-ogm-api</artifactId>
     <version>2.0.0-M01</version>
   </dependency>

   <dependency>
     <groupId>org.neo4j</groupId>
     <artifactId>neo4j-ogm-core</artifactId>
     <version>2.0.0-M01</version>
    </dependency>