Skip to content

Extend Codeanalyzer to Capture Database Entries #100

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:
classCRUDOperation {
privateCRUDOperationTypeoperationType; // An Enum with CREATE, READ, UPDATE, DELETEprivateintline = -1; // Source code location details
}
classCRUDQuery {
privateStringqueryString; // Raw SQL or JPQLprivateCRUDQueryTypequeryType; // An Enum with READ and WRITEprivateintline = -1; // Source code location details
}
  1. Integration with CallSite and Callable objects to track database operations:
classCallSite {
// Existing fields...privateCRUDOperationcrudOperation;
privateCRUDQuerycrudQuery;
}
classCallable {
// Existing fields...privateList<CRUDOperation> crudOperations = newArrayList<>();
privateList<CRUDQuery> crudQueries = newArrayList<>();
}

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

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