Spring Data neo4j translates neo4j's NotFoundException to an InvalidDataAccessResourceUsageException instead of an DataRetrievalFailureException

Showing 1-3 of 3 messages
Spring Data neo4j translates neo4j's NotFoundException to an InvalidDataAccessResourceUsageException instead of an DataRetrievalFailureException Florian B. 3/6/13 8:03 AM
We're using neo4j 1.8.2 Advanced with Spring Data neo4j 2.2.0.RELEASE and Spring Framework 3.2.0.RELEASE. We're using a lot of custom queries. The queries are defined using the @Query annotation in our repository interfaces. 

While writing tests we encountered a problem with one of our queries. As far as we know, when a query uses a start node which does not exists neo4j throws a NotFoundException which will be then translated to a DataRetrievalFailureException.

But for our query the exception is translated to an InvalidDataAccessResourceUsageException instead which normally indicates that the query is not correct. We think that our query looks good so we don't understand why the InvalidDataAccessResourceUsageException gets thrown. When we test it with an existing start node the query returns the expected results. 
   
 START person = node({0})
 MATCH person
-[attributeRel:ATTRIBUTE]-> attribute -[:ATTRIBUTE_CATEGORY]-> category
 WHERE attributeRel
.value! <> 'N' AND attributeRel.value! <> 'NA'
 RETURN category
, COLLECT(attribute), COLLECT(attributeRel)
 ORDER BY category
.name"


Is this a bug in Spring Data neo4j or is our query wrong or is the exception type correct and we just don't understand why it get's thrown. 

Cheers,
Florian
Re: Spring Data neo4j translates neo4j's NotFoundException to an InvalidDataAccessResourceUsageException instead of an DataRetrievalFailureException Michael Hunger 3/6/13 2:16 PM
It is probably a bug then, can you post the stacktrace for it?
Re: Spring Data neo4j translates neo4j's NotFoundException to an InvalidDataAccessResourceUsageException instead of an DataRetrievalFailureException Florian B. 3/7/13 12:53 AM
Hi Michael,

here's the stacktrace for the test.

at org.neo4j.kernel.impl.core.NodeManager.getNodeById(NodeManager.java:367)
at org.neo4j.kernel.InternalAbstractGraphDatabase.getNodeById(InternalAbstractGraphDatabase.java:894)
at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$3$$anonfun$apply$2.apply(IndexQueryBuilder.scala:95)
at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$3$$anonfun$apply$2.apply(IndexQueryBuilder.scala:95)
at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$.getElements(GetGraphElements.scala:37)
at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$3.apply(IndexQueryBuilder.scala:95)
at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$3.apply(IndexQueryBuilder.scala:95)
at org.neo4j.cypher.internal.pipes.matching.MonoDirectionalTraversalMatcher.findMatchingPaths(MonodirectionalTraversalMatcher.scala:42)
at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$createResults$1.apply(TraversalMatchPipe.scala:32)
at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$createResults$1.apply(TraversalMatchPipe.scala:29)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:388)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$class.foreach(Iterator.scala:660)
at scala.collection.Iterator$$anon$19.foreach(Iterator.scala:333)
at org.neo4j.cypher.internal.pipes.EagerAggregationPipe.createResults(EagerAggregationPipe.scala:76)
at org.neo4j.cypher.internal.pipes.ExtractPipe.createResults(ExtractPipe.scala:34)
at org.neo4j.cypher.internal.pipes.SortPipe.createResults(SortPipe.scala:39)
at org.neo4j.cypher.internal.pipes.ColumnFilterPipe.createResults(ColumnFilterPipe.scala:37)
at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:127)
at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:125)
at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:33)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:59)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:63)
at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:61)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:49)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:103)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:81)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:312)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy40.getAttributeCategories(Unknown Source)
at com.mycompany.product.model.person.repository.PersonRepositoryTest.test_getAttributeCategories_ExceptionThrown(PersonRepositoryTest.java:260)


On Wednesday, March 6, 2013 11:16:14 PM UTC+1, Michael Hunger wrote:
It is probably a bug then, can you post the stacktrace for it?