Thank you for your reply and I'm sorry that I made the mistake about the duplicate attribute.
So if my Book object is like:
@Node
public class Book
{
@Id
@GeneratedValue
private Long id;
@Relationship(direction = Relationship.Direction.OUTGOING, type = "WRITTEN_BY")
private Author authorWrittenBy;
@Relationship(direction = Relationship.Direction.INCOMING, type = "WROTE")
private Author authorWrote;
}
and I want to get the "authorWrittenBy" and "authorWrote" in the same time.
I just tried and the results would be:
①If I use the reactive crud method without customize query for example:
Flux<Book> findByName(String name);
@ParameterizedTest
@ValueSource(strings = {"Book Title"})
public void testFindByName(String name)
{
bookDao.findByName(name).toIterable()
.forEach(book -> {
System.out.println("Book: "+ book);
System.out.println("authorWrittenBy: "+ book.getAuthorWrittenBy());
System.out.println("authorWrote: "+ book.getAuthorWrote());
});
}
}
the result:
Book: Book [id=15, name=Book Title, price=100]
authorWrittenBy: Author{id=16, name='James', addr='Tokyo', age=30}
authorWrote: Author{id=16, name='James', addr='Tokyo', age=30}
②If I use the reactive crud method with customize query :
@Query("MATCH p = (b:Book{name:$name}) <-[:WROTE]- (a :Author) RETURN p")
Flux<Book> customFindByName1(String name);
the result:
Book: Book [id=15, name=Book Title, price=100]
authorWrittenBy: null
authorWrote: Author{id=16, name='James', addr='Tokyo', age=30}
③If I use the reactive crud method with customize query like you replied:
@Query("MATCH (b:Book{name:$name}) <-[:WROTE]- (a :Author) RETURN a, b")
Flux<Book> customFindByName2(String name);
the result:
Book: Book [id=15, name=Book Title, price=100]
authorWrittenBy: null
authorWrote: null
So I'm curious how to write the query could I get the result like ①.
I'm very sorry for the long question taking up your time, and I'd be very thankful if anyone could help me.