I have a base entity class BaseDictionary
:
@Entity
@Inheritance
public abstract class BaseDictionary {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
@Column(name = "code")
protected String code;
@Column(name = "is_enabled")
protected Boolean enabled = true;
}
any child classes
@Entity
@Table(name = DB.DIC_RIGHTS_TYPE, schema = DB.SCHEMA_DIC)
public class DicRightsType extends BaseDictionary {}
@Entity
@Table(name = DB.DIC_ROLES_TYPE, schema = DB.SCHEMA_DIC)
public class DicRolesType extends BaseDictionary {}
There are many child classes like this.
Given an entity class name like DicRightsType
I would like to get data from the table associated with the entity of that name. How is it possible to implement?
I wanted to use JPA repositories like this: Using generics in Spring Data JPA repositories but this does not suit my case because I only have the name of the entity class at runtime and do not know how to create a dynamic repository for the class.