Hibernate - createNativeQuery with “non-entity class” result

前端 未结 6 1904
清酒与你
清酒与你 2021-01-04 20:13

I\'m new to all this Hibernate/JPA stuff, so i will try to be as clear as possible.

Is there any way in Hibernate to use createNativeQuery to select a single/or mult

6条回答
  •  一向
    一向 (楼主)
    2021-01-04 20:45

    String SQL = ".."; //same SQL as you had before
    Query query = getEntityManager().createNativeQuery(SQL); //no entity mapping
    query.setParameter("idContact", 9293L);
    String string = (String)query.getSingleResult();
    System.out.println(string);
    

提交回复
热议问题