-
Notifications
You must be signed in to change notification settings - Fork 10
Extend Codeanalyzer to Capture Database Entries #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
🧠 Brain-dump 🧠Spring is actually a bit tricky. This is what we may have to do--- When we go the call site within a method say
Methodological noteThere is no explicit Moreover! The query in Spring can either be SQL or a dialect of SQL called JPQL. So the below tow are valid:
But, it seems like there are well maintained parsers for these two! Hibernate's HQL parser, and JSQLParser. |
🧠 Brain-dump 🧠In JPA, there is an ambiguity with determining whether Query q = entityManager.createQuery("DELETE FROM User u WHERE u.status = 'inactive'"); And then somewhere else, they may call the q.executeUpdate(); Note that the above two examples needn't be in the same method or even in the same class. Take the below example for instance-- public class QueryBuilder {
public static Query foo(EntityManager em) {
return em.createQuery("DELETE FROM User u WHERE u.status = 'inactive'");
}
} Then, in some other class-- public class UserService {
public void bar(EntityManager em) {
Query updateQuery = QueryBuilder.foo(em);
updateQuery.executeUpdate(); // UPDATE operation, but the execution context doesn't reveal that directly
}
} So, unless we do dataflow analysis on |
Uh oh!
There was an error while loading. Please reload this page.
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
andCRUDQuery
class to represent database operations with:@Query
,@Insert
,@Update
,@Delete
annotationspersist
,merge
,remove
,find
,executeQuery
,executeUpdate
)CallSite
andCallable
objects to track database operations:Describe alternatives you've considered
Additional context
The solution should support common Java persistence frameworks:
The text was updated successfully, but these errors were encountered: