Hi there,
I'm currently facing a porblem I'm unable to understand or solve:
If I create two new NodeTypes and then ask for the second one, I get a javax.jcr.query.InvalidQueryException.
Note that the first search works, only the second one fails.
If have no idea what is happening or what I maybe do wrong.
Any help is appreciated.
@RunWith(CdiTestRunner.class)
@TestControl(startScopes = ApplicationScoped.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CDITest {
  @Inject
  private Session session;
 
  private void regNodeType(Session repoSession, String typeName) throws RepositoryException{
  NodeTypeManager mgr = repoSession.getWorkspace().getNodeTypeManager();
  // Create a template for the node type ...
  NodeTypeTemplate type = mgr.createNodeTypeTemplate();
  type.setName(typeName);
  type.setDeclaredSuperTypeNames(new String[]{CrConstants.JCR_NT_UNSTRUCTURED});
  type.setAbstract(false);
  type.setOrderableChildNodes(true);
  type.setMixin(false);
  type.setQueryable(true);
  mgr.registerNodeType(type, true);
  }
  private void fireQuery(Session repoSession, String typeName) throws RepositoryException{
  Query query = repoSession.getWorkspace().getQueryManager().createQuery(
  "SELECT BASE.* FROM [" + typeName + "] AS BASE ", Query.JCR_SQL2);
  query.execute();
  }
  private Node saveNode(Session repoSession, String typeName) throws RepositoryException{
  Node root = repoSession.getNode("/");
  Node x = root.addNode("xyz:XYZ", typeName);
  repoSession.save();
  return x;
  }
 
  private void regNs(Session repoSession) throws RepositoryException{
  NamespaceRegistry reg = repoSession.getWorkspace().getNamespaceRegistry();
  reg.registerNamespace("xyz", "org://some");
  }
 
  @Test
  public void test000Schrott() throws RepositoryException {
  regNs(session);
  regNodeType(session, "xyz:pommes");
  fireQuery(session, "xyz:pommes");
  Node x = saveNode(session, "xyz:pommes");
  x.setProperty("some", "thing");
  regNodeType(session, "xyz:mayo");
  fireQuery(session, "xyz:mayo");
  }
}
EDIT: this is most likely a bug, the behavior should be consistent between the 2 node types.
Does ModeShape 3.x exhibit the same behavior in this case ?