1

一つ質問があります。私は 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;
//  }

私が次のことをしようとしているとき:

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);

ユーザー オブジェクト (u) にはプロパティが含まれません (PropertyGroup エンティティはマップされません)。

私は何を間違っていますか?どんな助けでも大歓迎です。

よろしく、

アレックス

4

1 に答える 1