code: protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId)
      throws CmsDataAccessException {
  
          ResultSet res = null;
          PreparedStatement stmt = null;
          Connection conn = null;
  
          int returnValue;
          try {
              // create statement
              conn = m_sqlManager.getConnection(dbc);
              stmt = m_sqlManager.getPreparedStatement(conn, projectId, "C_PROPERTIES_READALL_COUNT");
              stmt.setString(1, metadef.getId().toString());
              res = stmt.executeQuery();
  
              if (res.next()) {
                  returnValue = res.getInt(1);
                  while (res.next()) {
                      // do nothing only move through all rows because of mssql odbc driver
                  }
              } else {
                  throw new CmsDbConsistencyException(
                      Messages.get().container(Messages.ERR_NO_PROPERTIES_FOR_PROPERTYDEF_1, metadef.getName()));
              }
          } catch (SQLException e) {
              throw new CmsDbSqlException(
                  Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
                  e);
          } finally {
              m_sqlManager.closeAll(dbc, conn, stmt, res);
          }
          return returnValue;
      }
docs: Returns the amount of properties for a propertydefinition.<p>
  
  @param dbc the current database context
  @param metadef the propertydefinition to test
  @param projectId the ID of the current project
  
  @return the amount of properties for a propertydefinition
  @throws CmsDataAccessException if something goes wrong