Hello i have an problem with an inheritance query using JPA
(There is my Class Hierarchy)
+UsuarioGenerico (MappedSuperclass or Entity - but is Abstract)
-+Usuario (Entity)
-+UsuarioPorEmpresa (Entity)

Then, when i try make an select for Usuario, i not obtain results
i try with an NamedQuery:
@NamedQuery(name="Usuario.findAll", query="SELECT u FROM Usuario u")
i try with this, but not obtain results
@NamedQuery(name="Usuario.findAll", query="SELECT u FROM UsuarioGenerico u where TYPE(u) = Usuario")

public  class Usuario extends UsuarioGenerico implements Serializable {

    public static final String FIND_ALL = "Usuario.findAll";
}

then i use this in an DAO class, but not have results

public List<Usuario> findAll() {
    return super.findList(Usuario.FIND_ALL);
}

//
i try too with an generic, using CriteriaBuilder, but not have results (claseEntity = Usuario)

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public List<T> findAll() {
    CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
    cq.select(cq.from(claseEntity));
    return em.createQuery(cq).getResultList();
}

how i can obtain results for list all Usuarios? --- please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.