Toda vez que eu faço uma query nativa no JPA eu tenho que retornar todos os campos da tabela, teria alguma maneira de retorna só alguns?
Abaixo segue o exemplo:
this.getEntityManager().createNativeQuery( query, History.class ).setParameter( 1, limit ).getResultList();
Por exemplo nesta consulta o seu gostaria de retorna 2 campos da tabela history, mas tive que retornar todos porque eu recebia a seguinte exception:
Caused by: org.postgresql.util.PSQLException: The column name time_request was not found in this ResultSet.
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.findColumn(AbstractJdbc2ResultSet.java:2457)
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2324)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:240)...