Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@NamedNativeQuery and choosing the correct resultClass

 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Probably this is simple question, but I just can't find the answer. What should be in the place of XXXX in this query? I have been trying java.lang.String.class and java.lang.Long.class but it doesn't work...
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing, just do not include a resultClass. resultClass is only for SQL queries that are used to build Entity objects.
 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the answer ! ^^
 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to call one stored procedure using JPA entity manager. In my stored procedure i have some input parameters and some as out put parameters. Please suggest, how to call this.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA does not define any specific support for stored procedures or output parameters, native queries only directly support SQL returning a ResultSet.

Depending on what JPA provider and database you are using, there are some way to execute stored procedures.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Advanced_Topics#Stored_Procedures
 
Zaztz Zuraidah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Stachlewski wrote:Thanks a lot for the answer ! ^^


I don't get this. I am having the same problem.

How do you get the integer result then?

int count = theDao.findByNamedQuery("findCount",queryParams);

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic