Skip to content

Extend Codeanalyzer to Capture Database Entries #100

Open
0 of 2 issues completed
Open
Feature
0 of 2 issues completed
@rahlk

Description

@rahlk

Is your feature request related to a problem? Please describe

The codeanalyzer currently lacks database operation analysis capabilities. It cannot detect, represent or analyze CRUD (Create, Read, Update, Delete) operations in Java classes, making it difficult to understand database interactions and data flow in applications.

Describe the solution you'd like

Add a CRUDOperation and CRUDQuery class to represent database operations with:

  1. Detection of database-related methods/annotations:
  • @Query, @Insert, @Update, @Delete annotations
  • JDBC/JPA/Hibernate method calls (persist, merge, remove, find, executeQuery, executeUpdate)
  • SQL/JPQL strings in code
  1. Properties to capture:
class CRUDOperation {
    private CRUDOperationType operationType;  // An Enum with CREATE, READ, UPDATE, DELETE
    private int line = -1;       // Source code location details
}

class CRUDQuery {
    private String queryString;    // Raw SQL or JPQL
    private CRUDQueryType queryType;  // An Enum with READ and WRITE
    private int line = -1;       // Source code location details
}
  1. Integration with CallSite and Callable objects to track database operations:
class CallSite {
    // Existing fields...
    private CRUDOperation crudOperation;
    private CRUDQuery crudQuery;
}

class Callable {
    // Existing fields...
    private List<CRUDOperation> crudOperations = new ArrayList<>();
    private List<CRUDQuery> crudQueries = new ArrayList<>();
}

Describe alternatives you've considered

  • Parsing raw SQL strings - Limited, misses ORM operations
  • Static analysis of database calls - Complex implementation
  • Configuration-based approach - Less accurate, requires manual updates

Additional context

The solution should support common Java persistence frameworks:

  • Jakarta and JavaEE
  • Spring Data JPA
  • Hibernate
  • JDBC
  • MyBatis

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions