cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

@Relationshipproperty is not working with spring boot

mohamedrafeek
Node Link

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 

1 ACCEPTED SOLUTION

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

View solution in original post

9 REPLIES 9

Don’t you need a List<LangProperties> on line 7?

Even I tried to list also not working

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?  

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

 

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.

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

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!

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.

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