java – Spring Entities to avoid duplication of code

I've recently stumbled on a design issue that I'm not sure what the best course of action is.

When you use Spring Data JPA to create entity classes, I say:

INameEntity.java interface
CityNamesEntity.java
HumanNamesEntity.java
AnimalNamesEntity.java

They all have an identical logic, only functions addName (stringname) and getName () Without the use of entities, I would simply write a simple class that accesses the required table and processes those requests.

My question is. What is the best course of action?

  1. Leave it as it is.
  2. Ditch entities and implement a solution that will only switch the table, whichever is called.
  3. Database design is incorrect / The SQL database system choice is incorrect in this scenario.

Or maybe there is a design pattern that allows me to use entities that solve this problem in an elegant way.