Select specific columns from table with JPA in java -
i want write query getting specific columns.using
entitymanager.createquery("select u.name department u").getresultlist();
however returns object not instance of declaring class. correct way specific column table in jpa.as provider using hibernate
it returns list of objects (it hard jpa guess types returning). luckily can give hint typedquery
this
typedquery<string> query = em.createquery("select u.name department u", string.class); list<string> departmentnames = query.getresultlist();
wiki
Comments
Post a Comment