Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-11-2022 10:45 PM - edited 11-13-2022 10:31 PM
Hi Team,
I tried to relationship property in a spring boot application. Nodes created, but the relationship is not connected between the nodes.Code belows
@Node(value = "Person")
public class Person {
@Id
private String PersonId;
@Relationship(type = "has_primaryskill", direction = Direction.OUTGOING)
private LangProperties planguage;
}
@RelationshipProperties
public class LangProperties {
@TargetNode
private Language language;
@Id
@GeneratedValue
Long id;
@Property
private String values;
}
@Node(value = "Language")
public class Language {
@Id
private String tech;}
Problem: person and language nodes are created but relationship is not created.Please help on this issue
Spring boot version as 2.6 and maven neo4j version as 5.1.0 @neo4j @gerrit_meier @gerrit_meier1 @octav_stanciu00
Solved! Go to Solution.
11-18-2022 03:29 AM
Hi ,
I actually use neo4j and neo4j maven dependence spring data. Because of the two dependencies facing the above problem. After removing neo4j dependency its working fine
11-11-2022 11:11 PM
Don’t you need a List<LangProperties> on line 7?
11-12-2022 12:05 AM
Even I tried to list also not working
11-12-2022 01:01 AM
Not sure it matters since your code must compile, but the manual has @RelationshipId as the annotation for the is in the RelationshipProperties class.
Is your relationship type in the database “has_primaryskill” or all uppercase as usually practiced?
11-12-2022 01:53 AM
RelationshipId tried but still facing the issue.
Without relationship property is it working fine.but we required relationship property.could you help on this issue,
Neo4j maven version used as4.0.0
11-13-2022 10:43 PM
I faced the same issue once. You should also have an Incoming relationship in Language as well but I am not so sure about it. Try it and leave a feedback. And also like @glilienfield mentioned, remove @Id and @GeneratedValue and replace them with @RelationshipId and put it before private Language language.
11-13-2022 10:55 PM
In Language class need to add like incoming relationship with person ?.
If i tried with query level to add the property in relationship its working fine .But tried from spring boot its not working
11-13-2022 11:02 PM - edited 11-13-2022 11:02 PM
Yes. I am leaving you an example of a user-movie relationship and the user can review a movie.
User entity:
@Node("USER") |
@Getter |
@Setter |
@AllArgsConstructor |
@NoArgsConstructor |
@ToString |
public class User { |
@Id |
@GeneratedValue |
private Long id; |
private Integer age; |
private String email; |
private String name; |
private String password; |
@Relationship(type = "REVIEWED", direction = Relationship.Direction.OUTGOING) |
private Collection<Reviewed> reviewedMovies; |
} |
Movie entity:
@Node("MOVIE") |
@Getter |
@Setter |
@AllArgsConstructor |
@NoArgsConstructor |
@ToString |
public class Movie { |
@Id |
@GeneratedValue |
private Long id; |
private String name; |
private String genre; |
private Integer releaseYear; |
private String imageURL; |
private String description; |
@Relationship(type = "REVIEWED", direction = Relationship.Direction.INCOMING) private List<ReviewedByUser> reviewedByUsers; |
And the ReviewedByUser relationship entity:
@data |
@RelationshipProperties |
public class ReviewedByUser { |
@RelationshipId |
private Long id; |
@TargetNode |
private User User; |
String content; |
} |
I don't know why these tables were created when I pasted the code. Hope this helps!
11-14-2022 10:23 AM
This should work fine. And place, if you don't need it, don't create bidirectional relationships (as advised).
Could you please show the exact code of the entities? Are you using Lombok and/or have custom equals/hashCode?
Also the calling code that creates the two nodes with the relationship might be helpful.
11-18-2022 03:29 AM
Hi ,
I actually use neo4j and neo4j maven dependence spring data. Because of the two dependencies facing the above problem. After removing neo4j dependency its working fine
All the sessions of the conference are now available online