docs: NodeDefinitionId nodeDefinitionId() throws ItemNotFoundException, ConstraintViolationException, RepositoryException {
          CachedDefinition defn = cachedDefn;
          NodeTypes nodeTypes = session().nodeTypes();
          if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) {
              assert !this.isRoot();
              // Determine the node type based upon this node's type information ...
              CachedNode parent = getParent().node();
              SessionCache cache = sessionCache();
              Name nodeName = name();
              Name primaryType = node().getPrimaryType(cache);
              Name parentPrimaryType = parent.getPrimaryType(cache);
              Set<Name> parentMixins = parent.getMixinTypes(cache);
              SiblingCounter siblingCounter = SiblingCounter.create(parent, cache);
              boolean skipProtected = true;
              NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins);
              JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected,
                                                                                  siblingCounter);
              if (childDefn == null) {
                  throw new ConstraintViolationException(JcrI18n.noChildNodeDefinition.text(nodeName, getParent().location(),
                                                                                            readable(parentPrimaryType),
                                                                                            readable(parentMixins)));
              }
              NodeDefinitionId id = childDefn.getId();
              setNodeDefinitionId(id, nodeTypes.getVersion());
              return id;
          }
          return defn.nodeDefnId;
      }