0

Problem:

I need to find out which database entities (and fields of those entities) are used by a certain Gradle module (which has multiple dependencies to other modules which contain those entities). I need to do this because some entities in the database are going to be moved to a different place and I need to find out if this is an issue for the respective module.

The question would be:

Will the module still be executable after I removed those entities from the database?

The seemingly easy solution:

Why don't I just run through the code of the module (and the modules it depends on) and find the entities?

Because the modules are huge and there are multiple hundred entities which might be used.

What did I try so far?

  • I started with an entity relationship diagram but this does not tell me which pieces of the code are using the entities.
  • Next, I ran some static code analyis (Analyze dependencies...) using IntelliJ which returns a huge list of used classes (~1.000) in other modules but I would need to manually open them all to find out if it's an entity. On top, the analysis does not tell me which of this entity's attributes is used.

What do I expect?

I want a list of entity attributes which are needed to be present in the databse so that the module can still be executed.

  • Not really possible. Your best bet is to search for `@Entity` to find all the classes which are mapped to the database. And every field that is not annotated with `@Transient` must be present in the database – XtremeBaumer Mar 08 '23 at 09:06
  • Thanks for the feedback. When I search for `@Entity` in all modules it depends on, I get hundreds of entities with a lot not being needed by that specific module. When I search for `@Entity` in the respective module-folder *only*, I will overlook many entities which the module depends on indirectly. – l-hofmann Mar 08 '23 at 09:10
  • Then your best bet is to inspect the database access by that specific module. If done properly, you should be able to find all necessary entities in the data access layer – XtremeBaumer Mar 08 '23 at 09:15

0 Answers0