Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@RelationshipEntity not hydrated [DATAGRAPH-961] #1525

Closed
spring-projects-issues opened this issue Jan 24, 2017 · 6 comments
Closed

@RelationshipEntity not hydrated [DATAGRAPH-961] #1525

spring-projects-issues opened this issue Jan 24, 2017 · 6 comments
Labels
in: core Issues in core support type: regression A regression from a previous release
Milestone

Comments

@spring-projects-issues
Copy link

Agostino Semeria opened DATAGRAPH-961 and commented

The same code, executed with the new snapshot version of spring-data-neo4j (4.2.0.BUILD-20170123.104601-200) doesn't return the existent relationship

@Query("MATCH (a:User) - [r:FRIEND_WITH] -> (b:Person) RETURN r, a, b")
FriendshipEntity loadFriendship(...);

@RelationshipEntity(type="FRIEND_WITH")
public class FriendshipEntity {
    @GraphId   private Long relationshipId;
    @StartNode private User user;
    @EndNode   private Person person;
}

The same code executed with the previous version (4.2.0.BUILD-20161223.121144-184) works well


Affects: 4.2 RC1 (Ingalls), 4.2 GA (Ingalls)

Reference URL: http://stackoverflow.com/questions/41824592/relationshipentity-not-hydrated

Attachments:

Backported to: 4.2.1 (Ingalls SR1)

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

G'Kar commented

Hi there,

I might have encountered a related issue. I'm able to retrieve a RelationshipEntity with the following query:

@Query("match (p:PostNode) - [pr:POST_RECEPTION] -> (rn:ReceivedPostsNode) where p.postID={0} and pr.postRetrieved = FALSE and rn.userid = {1} return p, rn, pr")
public PostReceptionRel findBypostId(String postId, String userid);

My relationship entity is as follows:

@RelationshipEntity(type = "POST_RECEPTION")
public class PostReceptionRel
{
	@GraphId	Long id;
	private boolean postRetrieved = false;
	private boolean postRead = false;
	@StartNode	private PostNode postNode = null;
	@EndNode	private ReceivedPostsNode receivedPostsNode = null;
}

However if I update the relationship a phantom node is created which screws up a lot of subsequent procedures. Please see attached screenshot.

I'm using:
spring-data-neo4j:5.0.0.M1
neo4j-ogm-bolt-driver:2.1.0

@spring-projects-issues
Copy link
Author

Agostino Semeria commented

According to this commit neo4j/neo4j-ogm@7712030
before this modification on method getRelationshipEntity() (https://github.com/neo4j/neo4j-ogm/blob/771203031c0f0ffbc528ac1a9cc1d1db5e8cc3d9/core/src/main/java/org/neo4j/ogm/context/GraphEntityMapper.java#L505) it was not needed to have e reference to the relationship entity in either the source or target node.

Which is the right behaviour?

@spring-projects-issues
Copy link
Author

Nicolas Mervaillie commented

Can you detail your use case pls ?
Having to declare the relationships in your entities is problematic for you ?

@spring-projects-issues
Copy link
Author

Agostino Semeria commented

Before the 4.2.0 this code worked well

@Query("MATCH (a:User) - [r:FRIEND_WITH] -> (b:Person) RETURN r, a, b")
FriendshipEntity loadFriendship(...);
 
@RelationshipEntity(type="FRIEND_WITH")
public class FriendshipEntity {
    @GraphId   private Long relationshipId;
    @StartNode private User user;
    @EndNode   private Person person;
}

@NodeEntity(label = "User")
public class User {
    @Property(name = "firstName")
    private String mFirstName;

    @Property(name = "lastName")
    private String mLastName;

    public String getFirstName() {
        return mFirstName;
    }

    public void setFirstName(String pFirstName) {
        mFirstName = pFirstName;
    }

    public String getLastName() {
        return mLastName;
    }

    public void setLastName(String pLastName) {
        mLastName = pLastName;
    }
}
@NodeEntity(label = "Person")
public class Person {
    @Property(name = "firstName")
    private String mFirstName;

    @Property(name = "lastName")
    private String mLastName;

    public String getFirstName() {
        return mFirstName;
    }

    public void setFirstName(String pFirstName) {
        mFirstName = pFirstName;
    }

    public String getLastName() {
        return mLastName;
    }

    public void setLastName(String pLastName) {
        mLastName = pLastName;
    }
}

After the 4.2.0 to make this code works I need to add this properties at least to User entity (source entity of the relationship)

@Relationship(type = "FRIEND_WITH")
 private FriendshipEntity mFriendship;

@spring-projects-issues
Copy link
Author

Nicolas Mervaillie commented

Sorry I've been unclear.

I've seen that the behavior changed since 4.2.
What I try to understand is : what's the use case of not specifying the relations in your entities ?
To me, it is unusual to navigate only from relation to entity, and not the inverse.

Is it a strong requirement for you ?
Would adding the relationship be problematic for you ?

@spring-projects-issues
Copy link
Author

Nicolas Mervaillie commented

fixed by neo4j/neo4j-ogm#309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

1 participant