Results 1 to 3 of 3

Thread: Repository derived query not working with Strings that have spaces

  1. #1
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default Repository derived query not working with Strings that have spaces

    Using Neo4j 1.5 GA
    Using Spring Data Neo4j 2.0.0.RELEASE

    I was thinking that If I had a property that was a String, but the values might have spaces, wouldn't be a problem for derived queries. But everytime I try to use the derived query with a String that has spaces, it throughs a NullPointerException.

    Here's my Repository

    Code:
    public interface ItemRepository extends GraphRepository<Item> {
    
        Page<Item> findByDescriptionLike(String title, Pageable page);
    
        Item findByDescription(String description);
    }
    Here's the line of code that throws the NPE.

    Code:
    Item lookupDrPepperByFullDescription = itemRepository.findByDescription("Dr Pepper 6 pack");
    And here is the exception stack trace

    Code:
    java.lang.NullPointerException
    	at org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)
    	at org.apache.lucene.util.StringHelper.intern(StringHelper.java:36)
    	at org.apache.lucene.index.Term.<init>(Term.java:38)
    	at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)
    	at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1421)
    	at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1309)
    	at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1266)
    	at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1226)
    	at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
    	at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:281)
    	at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:207)
    	at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:218)
    	at org.neo4j.cypher.ExecutionEngine$$anonfun$createStartPipe$3.apply(ExecutionEngine.scala:194)
    	at org.neo4j.cypher.ExecutionEngine$$anonfun$createStartPipe$3.apply(ExecutionEngine.scala:192)
    	at org.neo4j.cypher.pipes.StartPipe$$anonfun$foreach$1.apply(StartPipe.scala:35)
    	at org.neo4j.cypher.pipes.StartPipe$$anonfun$foreach$1.apply(StartPipe.scala:34)
    	at org.neo4j.cypher.pipes.ParameterPipe.foreach(ParameterPipe.scala:27)
    	at org.neo4j.cypher.pipes.StartPipe.foreach(StartPipe.scala:34)
    	at org.neo4j.cypher.pipes.TransformPipe.foreach(TransformPipe.scala:38)
    	at org.neo4j.cypher.pipes.ColumnFilterPipe.foreach(ColumnFilterPipe.scala:35)
    	at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
    	at org.neo4j.cypher.pipes.Pipe.map(Pipe.scala:31)
    	at org.neo4j.cypher.ExecutionResult$class.javaIterator(ExecutionResult.scala:49)
    	at org.neo4j.cypher.pipes.ColumnFilterPipe.javaIterator(ColumnFilterPipe.scala:25)
    	at org.neo4j.cypher.javacompat.ExecutionResult.iterator(ExecutionResult.java:51)
    	at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:258)
    	at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.singleOrNull(QueryResultBuilder.java:88)
    	at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:96)
    	at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70)
    	at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.execute(DerivedCypherRepositoryQuery.java:34)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301)
    	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:202)
    	at $Proxy33.findByDescription(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
    	at $Proxy34.findByDescription(Unknown Source)
    	at com.perfectworldprogramming.eventgate.item.ItemDBTests.testRetrievalByDescription(ItemDBTests.java:74)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
    	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
    	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
    It looks like somewhere between Neo4j and Lucene, it is parsing my String and passing in null to Lucene for the search string, or something like that. Going to do a test with the Template to see if the same thing happens running another query. That doesn't work for me either, but a different error, probably from my misunderstanding of the template class method lookup, which I tried to use.

    Thanks

    Mark
    Last edited by bytor99999; Jan 10th, 2012 at 03:25 PM. Reason: Add more

  2. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    We discussed this issue also on the Neo4j mailing list.
    This is an issue with lucene indexing - you can either have spaces, then you have to quote the full string but no wildcards, or you can have wildcards, then you probably have to split the query on spaces and do an "AND" combination.

    See this Mailinglist POST: https://groups.google.com/group/neo4...f47770f7b17e09

  3. #3
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •