Finding where your code depends on the values of returned columns

With the pureQuery Analysis view, you can see all of the Java statements in a pureQuery application that depend on the column values that are returned by an SQL query.

About this task

You might find this information useful if you want to change a field in your Java application and need to know which statements the change will affect.

Another situation in which this analysis can be useful is when the name of a column in a database is proposed to be changed. You can use the results of the analysis to estimate the changes that need to be made in your application and to find all SQL statements that the change would invalidate.

You can also use this analysis if your application queries private database columns and you want to be sure that the returned values for these columns will not appear in reports that your application generates.

To find these Java statements, pureQuery uses source code analysis, which is the process of analyzing code without running it.

The SELECT statements that return the column values can contain JOIN and WITH clauses.

Procedure

To see all of the statements in a pureQuery application that depend on the values that an SQL query returns:

  1. Tell pureQuery which column values to analyze your code's dependence on.
    • If you are using annotated methods:
      • To analyze the value of a single column in a result set that a SELECT statement returns, right-click a column name or column alias in the SELECT statement in the declaration of the method. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example will analyze the value for the column CATLOG.
        // Select all CATALOGs
        @Select(sql="select NAME, CATLOG from \"CATALOG\"")
        Iterator<Catalog> getCatalogs();
      • To analyze the values of all columns in a result set that a SELECT statement returns (except those columns that are defined by expressions), right-click anywhere within the SELECT statement in the declaration of the method, except in a column name. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example places the cursor on the word SELECT.
        // Select all CATALOGs
        @Select(sql="select NAME, CATLOG from \"CATALOG\"")
        Iterator<Catalog> getCatalogs();
      • Another way to analyze the values of all columns in a result set that a SELECT statement returns is to right-click a call to the annotated method that is declared with the SELECT statement. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example places the cursor in the getCatalogs() method.
        Iterator<Catalog> getCatalogs = data.getCatalogs();
      • The declaration for the method getCatalogs() might look like the declarations in the previous two examples.
    • If you are using inline methods:
      • To analyze the value of a single column in a result set that a SELECT statement returns, right-click a column name or column alias in the SELECT statement in a method call. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example will analyze the value for the column NAME.
        Iterator<Catalog> getCatalogs = db.queryIterator ("select NAME as CATALOG_NAME,  CATLOG from \"CATALOG\"", Catalog.class);
      • Another way to analyze the value of a single column in a result set that a SELECT statement returns is to right-click a column name or column alias in a SELECT statement that is used to initialize a variable. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example will analyze the value for the column NAME.
        @Sql String sqlStmt = "select NAME, CATLOG from \"CATALOG\"";
        Iterator<Catalog> getCatalogs = db.queryIterator ("select NAME as CATALOG_NAME,  CATLOG from \"CATALOG\"", Catalog.class);
      • To analyze the values of all columns in a result set that a SELECT statement returns (except those columns that are defined by expressions), right-click anywhere within the SELECT statement in a method call, except in a column name. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example places the cursor on the word SELECT.
        Iterator<Catalog> getCatalogs = db.queryIterator ("select NAME, CATLOG from \"CATALOG\"", Catalog.class);
      • Another way to analyze the values of all columns in a result set that a SELECT statement returns is to right-click anywhere within in a SELECT statement that is used to initialize a variable, except in a column name. Then, select Data Access Development > Source Code Analysis > Analyze Column Value Dependency.
        The following example places the cursor on the word SELECT.
        @Sql String sqlStmt = "select NAME, CATLOG from \"CATALOG\"";
        Iterator<Catalog> getCatalogs = db.queryIterator (sqlStmt, Catalog.class);
  2. Look in the pureQuery Analysis view to see the Java statements that use the analyzed values. This view organizes its entries into the following hierarchy:
    • Java project
      • Java package
        • Java file which contains the statement from which you started the source code analysis
          • The statement from which you started the source code analysis
            • Java statements that depend on the selected values

What to do next

If any of the columns have data types that are marked private in a domain model, they appear in the view with this indicator: Privacy indicator For information about marking data types as private, see Adding data privacy information to domain data types.

Right-click a line of code and select Show in source to open the source file in the Java editor. The line is highlighted in the editor.

Stop an analysis that is taking too long by clicking Cancel button.

Filter results by clicking the down arrow at the top of the view and clicking Filter button to open the Filter window.

Clear results by clicking Clear button.


Feedback