-
Notifications
You must be signed in to change notification settings - Fork 617
Missing converter from java.util.Map
to org.neo4j.driver.Value
.
#2576
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
Comments
Please tell us the error thrown. |
Sorry, My mistake. My problem is, that the above query does not throw any error but also they don't create a relationship and also do not return any value. |
SDN does a lot of logging. If you set The query here is correct, and depending on the parameters, it should create a relation. |
i got this type error. |
So you do get an error? I am confused. |
I apologize for this, but I got this type of error. |
Just tagging @michael-simons and @meistermeier as you would be more familiar. |
Your query is fine.
But without your model, the repo and your call site I cannot reproduce it. Actual parameter values would help too.
Thanks.
|
Okay, Let me try to explain a bit. List<Map<String,String>> list = new ArrayList<>();
Map<String,String> map = new HashMap<>():
map.put("stuGuid",23232)
map.put("collegeGuid",87833)
list.add(map) Now, This list passes to the below query. The Query is : @Query("""
UNWIND {0} AS row
MATCH (student:Student{guid:row.stuGuid}), (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college) RETURN student.guid"""
)
List<String> addStudentToCollege(List<Map<String, String>> list); Model: @Node
class Student{
private String guid;
@Relationship(type = "STUDENT_OF", direction = Direction.OUTGOING)
private College college;
}
@Node
class College{
private String guid;
} Here in this scenario, I get an Error that I already mention above. |
java.util.Map
to org.neo4j.driver.Value
.
Thanks, @Bhavinpanchal20 This will be fixed and is an enhancement. In the meantime you can use the following workaround.
Note that I rewrote the query to use modern parameters ( The parameter is now of type @Test
void listOfMapsShouldBeUsableAsArgumentsWithWorkaround(@Autowired Neo4jTemplate template, @Autowired CollegeRepository collegeRepository) {
var student = template.save(new Student("S1"));
var college = template.save(new College("C1"));
var pair = Map.of("stuGuid", student.getGuid(), "collegeGuid", college.getGuid());
var listOfPairs = List.of(Values.value(pair));
var uuids = collegeRepository.addStudentToCollegeWorkaround(listOfPairs);
assertThat(uuids).containsExactly(student.getGuid());
} Thanks again for reporting. One final advise, if you allow: Please use 3 consecutive tickmarks ` before and after a code snippet to format it proper. This really helps us a lot. I edited one of your answers to demonstrate. |
@michael-simons Thank you so much for giving me an example, we really appreciate that. But In your example you pass only one map but what about if I have a List of maps then how do I pass that dataset in the Value object? Suppose I have this type of dataSet, Map<String,String> map2 = new HashMap<>(): Now how i pass the list in List of Value? |
That would be @Test
@Tag("GH-2576")
void listOfMapsShouldBeUsableAsArgumentsWithWorkaround(@Autowired Neo4jTemplate template,
@Autowired CollegeRepository collegeRepository) {
Student student = template.save(new Student("S1"));
College college = template.save(new College("C1"));
Student student2 = template.save(new Student("S2"));
College college2 = template.save(new College("C2"));
Map<String, String> pair = new HashMap<>();
pair.put("stuGuid", student.getGuid());
pair.put("collegeGuid", college.getGuid());
Map<String, String> pair2 = new HashMap<>();
pair2.put("stuGuid", student2.getGuid());
pair2.put("collegeGuid", college2.getGuid());
List<Value> listOfPairs = Arrays.asList(Values.value(pair), Values.value(pair2));
List<String> uuids = collegeRepository.addStudentToCollegeWorkaround(listOfPairs);
assertThat(uuids).containsExactlyInAnyOrder(student.getGuid(), student2.getGuid());
} |
@michael-simons Thank you so much for giving the example. Now we resolve that issue. Currently, we try to upgrade SDN 6 also much appreciate for you build SDN 6 from Scratch. Thanks again for your quick support :) |
Thanks a lot, @Bhavinpanchal20 for your kind feedback, much appreciated. Let us know in case you run into more issues. |
The below query works fine in SDN 5, But in SDN 6 they throw error.
UNWIND {0} AS row
MATCH (student:Student{guid:row.stuGuid}), (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college)
RETURN student.guid
public List addOwnerOfActvities(List<Map<String,String>> data);
Can anyone tell me How I resolve that issue?
The text was updated successfully, but these errors were encountered: