-
Notifications
You must be signed in to change notification settings - Fork 619
Description
Sledge Hammer opened DATAGRAPH-1437 and commented
Using the Movies data set, in previous versions, I had a Movie repo as:
@Query("MATCH path=shortestPath((p1:Person)-[*0..15]-(p2:Person)) WHERE toLower(p1.name) = toLower($from) AND toLower(p2.name) = toLower($to) " +
"RETURN relationships(path) AS relationships, nodes(path) AS nodes")
public List<Map<String, Object>> findShortestPath(String from, String to);In the current version, this throws an exception in SingleValueMappingFunction:
Records with more than one value cannot be converted without a mapper.
No documentation on how to implement this in 6.0. I tried the following:
- consume a bean of Driver and do a query. This resulted in an exception:
Result result = driver.session().run("MATCH path=shortestPath((p1:Person)-[*0..15]-(p2:Person)) WHERE toLower(p1.name) = toLower('Al Pacino') AND toLower(p2.name) = toLower('Kevin Bacon') " +
"RETURN relationships(path) AS relationships, nodes(path) AS nodes");
List<Record> rows = result.list();
org.neo4j.driver.exceptions.ClientException: Database access is not allowed for user 'movies' with roles [movies_reader].
at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:143)
at org.neo4j.driver.internal.InternalResult.blockingGet(InternalResult.java:128)
at org.neo4j.driver.internal.InternalResult.list(InternalResult.java:105)- tried with a bean of Session, no bean found
- tried with a bean of Neo4jTemplate, same exception as Spaces after header names in template.mf #1
- tried with a bean of Neo4jClient, same exception as Spaces after header names in template.mf #1
- I was able to finally get it, at least executing as:
QueryRunner queryRunner = Neo4jTransactionManager.retrieveTransaction(driver, "movies");
if (queryRunner == null) {
queryRunner = driver.session(Neo4jTransactionUtils.defaultSessionConfig("movies"));
}
Result result = queryRunner.run("MATCH path=shortestPath((p1:Person)-[*0..15]-(p2:Person)) WHERE toLower(p1.name) = toLower('kevin bacon') AND toLower(p2.name) = toLower('al pacino') " +
"RETURN relationships(path) AS relationships, nodes(path) AS nodes");So issue #1, it seems like methods #1, 3 & 4 are not carrying the credentials properly?
Issue #2 is this result is very low level, is there a higher level abstraction for path queries as there was in previous versions?
Re the permissions, my config class is as followings and entity queries through a Neo4jRepository with custom queries are not having the permissions issue:
@Configuration
@EnableNeo4jRepositories(basePackages="org.xxx.yyy.movies.repositories",
transactionManagerRef="moviesTransactionManager")
public class MoviesDataSourceConfig {
private final Environment environment;
@Autowired
public MoviesDataSourceConfig(Environment environment) {
this.environment = environment;
}
@Bean
public Driver moviesDriver() {
return GraphDatabase.driver(Preconditions.checkNotNull(this.environment.getProperty("org.neo4j.driver.movies.uri")),
AuthTokens.basic(Preconditions.checkNotNull(this.environment.getProperty("org.neo4j.driver.movies.authentication.username")),
Preconditions.checkNotNull(this.environment.getProperty("org.neo4j.driver.movies.authentication.password"))));
}
@Bean
protected DatabaseSelectionProvider moviesDatabaseSelectionProvider() {
return DatabaseSelectionProvider.createStaticDatabaseSelectionProvider("movies");
}
@Bean
public Neo4jTransactionManager moviesTransactionManager(@Qualifier("moviesDriver") Driver driver,
@Qualifier("moviesDatabaseSelectionProvider") DatabaseSelectionProvider databaseSelectionProvider)
{
return new Neo4jTransactionManager(driver, databaseSelectionProvider);
}
}Affects: 6.0.1 (2020.0.1)
Issue Links:
- DATAGRAPH-1441 Register necessary callbacks internally inside the mapping context
Backported to: 6.0.2 (2020.0.2)