Cannot execute query after node move
jacobilsoe Dec 2, 2015 9:08 AMHi.
I am using ModeShape 4.2.0 and I have a problem executing a query which involves a node that was moved. I tweaked the test case org.modeshape.jcr.JcrWorkspaceTest.shouldAllowMoveFromPathToAnotherPathInSameWorkspace to mimic my production code but the test passes:
@Test
public void shouldAllowMoveFromPathToAnotherPathInSameWorkspace() throws Exception {
workspace.move("/a/b", "/b/b-copy");
JcrValueFactory valueFactory = session.getValueFactory();
String statement = "SELECT * FROM [nt:base] WHERE PATH([nt:base]) LIKE $path";
QueryManager queryManager = workspace.getQueryManager();
Query query = queryManager.createQuery(statement, Query.JCR_SQL2);
query.bindValue("path", valueFactory.createValue("/b/b-copy" + "/%"));
NodeIterator iterator = query.execute().getNodes();
}
In production I get this error when executing the query and iterating the nodes:
Caused by: org.modeshape.jcr.cache.NodeNotFoundInParentException: Cannot locate child node: a0ef31f7505d6460f4b84f-34f7-44d4-9573-3c19860e8d3a within parent: a0ef31f7505d64228e2e49-394e-47e8-8d7d-de3752db33de
at org.modeshape.jcr.cache.document.LazyCachedNode.parentReferenceToSelf(LazyCachedNode.java:247) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.cache.document.LazyCachedNode.getSegment(LazyCachedNode.java:284) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.cache.document.LazyCachedNode.getPath(LazyCachedNode.java:293) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.ScanningQueryEngine$24.getValueInRow(ScanningQueryEngine.java:1922) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.ScanningQueryEngine$DynamicOperandFilter.isCurrentRowValid(ScanningQueryEngine.java:2514) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.ScanningQueryEngine$RowFilterSupplier.isCurrentRowValid(ScanningQueryEngine.java:2548) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence$23.findNext(NodeSequence.java:1866) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence$23.hasNext(NodeSequence.java:1849) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence$23.findNext(NodeSequence.java:1863) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence$23.hasNext(NodeSequence.java:1849) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence$SingleWidthBatch.<init>(NodeSequence.java:1920) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.NodeSequence.copy(NodeSequence.java:1907) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.process.RestartableSequence.loadBatch(RestartableSequence.java:213) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.process.RestartableSequence$1.nextBatch(RestartableSequence.java:92) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.engine.process.RestartableSequence.nextBatch(RestartableSequence.java:119) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.JcrQueryResult$QueryResultIterator.findNextBatch(JcrQueryResult.java:257) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
at org.modeshape.jcr.query.JcrQueryResult$QueryResultIterator.hasNext(JcrQueryResult.java:241) [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
I can get the child nodes of the moved node by using the getNodes method but for performance reasons I would prefer using a query.
Any suggestions?
Thanks,
Jacob