Description
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:
- 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
- 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
}
- Integration with
CallSite
andCallable
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