I have a repository class that implements from another a method to get all my clients
@Repository
public class ClienteRepositoryImpl implements ClienteRepository{
private EntityManager em;
@Override
@Transactional(readOnly = true)
public List<ClienteEntity> findAll() {
return em.createQuery("from Cliente").getResultList();
}
}
The problem is that in the return line it throws me the following warning
Type safety: The expression of type List needs unchecked conversion to conform to List
I have searched in different places and it is not so clear to me why Java throws this at me. I have also read some questions on the subject in English, such as this one where the use of the @SuppressWarnings("unchecked") tag is even recommended, as well as disabling the warnings that cannot be avoided, something that for me is a bad practice .
How could I avoid this type of warning without the use of tags like the one mentioned?
You can try one
TypedQuery
: