I'm trying to extend a library that uses generics in entities and entities manager, so I have the following:
public class MyEntity extends ParentEntity extends BaseEntity
and
public class MyEntityManager extends ParentEntityManager extends BaseEntityManager<ParentEntity, ParentEntityDao>
Now my problem is, I'm using another class of the library to update the entity, and the method I need to call expects:
public <ENT extends BaseEntity> void update (Class<ENT> entityClass, BaseEntityManager<ENT> entityManager)
So when I try to call the method with MyEntity and MyEntityManager, it fails because my EntityManager extends from the BaseEntityManager with ParentEntity as parameter, not MyEntity, so they don't match.
I would say that the cleanest way to solve this would be to copy the utility class that has the update method and extend it in my project, but I would like to make it generic so I can pass it EntityManagers that use any children class of ParentEntity, but I've been trying for a while and I cannot find the solution.
I tried changing the method signature to this:
public <ENT extends BaseEntity> void update (Class<ENT> entityClass, BaseEntityManager<? extends ENT> entityManager)
but I'm still getting a compiler exception...
EDIT: Modifying ParentEntityManager, BaseEntityManager or ParentEntity is not possible, since there are too many dependencies to those classes