• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA - Projecting a single unique field.

 
Sreyan Chakravarty
Ranch Hand
Posts: 65
Firefox Browser MyEclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say I have an entity called Employee with a String persistent field called "id". Now say by using a JPQL query I only wish to project the id of a particular employee. What will be the return type of that query ? List<Object[]> or String ? I am confused since I heard that project queries returns only List<Object[]> but in this case it makes more sense to return only a String object.

Also how would I write such a query ?



Would the above query work ?

Also what would be the return type of aggregate functions like COUNT or SUM ? Single integer or list of Objects ?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Persistence WikiBook to the rescue! Have a look at the Select Queries section.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic