• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doing a count(*) in a named query

 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been told to create a named query within an entity class that performs a count on the table.
In JDBC, I could do this and get an int. However, I'm not sure how to do this within the framework
I've been given. Can someone offer any suggestions with this???

Thanks,

John
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, the next question is, 'what framework have you been given?'
 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cameron,

Sorry, I guess by framework, I meant how the boss wants it done, nothing
technology specific. We're using JPA and toplink. Other than that, not sure what you
need... It's not using Spring/Hibernate....etc.

John
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JPA try something like:


...


 
John Gregory
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

Thanks, I'll give that a try.

John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic