Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2275

javax.jcr.query.InvalidQueryException: Table does not exist. when adding multiple nodetypes

XMLWordPrintable

      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");
          }
      }
      

              hchiorean Horia Chiorean (Inactive)
              bes82 Bjoern Schmidt (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: