JPA 2.0 native query results as map

后端 未结 3 716
难免孤独
难免孤独 2020-12-01 14:25

I run a JPA 2.0 native query like this:

Query query = em.createNativeQuery(\"SELECT NAME, SURNAME, AGE FROM PERSON\");
List list = query.getResultList();
         


        
3条回答
  •  感动是毒
    2020-12-01 14:42

    Take a look on this I got it when working on project that I could not use all JPA features so I tried the traditional jdbc method even if I would not recommend this but it's working for me.

    @LocalBean
    public class TCotisationEJB {
    
        @PersistenceContext(unitName="ClaimsProjectPU")
        private EntityManager em;
    
        @TransactionAttribute(TransactionAttributeType.NEVER)
        public List getCotisation(){
            Query query=em.createNativeQuery("select Annee,Mois,RetSonarwa from TCotisMIFOTRA2008 where matricule='10000493' order by Annee");
            List cotisation=query.getResultList();
            Object[] cotisationData;
    
             for(int i=0;i

提交回复
热议问题