my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes @NamedNativeQuery and choosing the correct resultClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "@NamedNativeQuery and choosing the correct resultClass" Watch "@NamedNativeQuery and choosing the correct resultClass" New topic
Author

@NamedNativeQuery and choosing the correct resultClass

Tom Kowalski
Ranch Hand

Joined: Feb 17, 2009
Posts: 72


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...


SCJP, SCWCD, OCUP
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Nothing, just do not include a resultClass. resultClass is only for SQL queries that are used to build Entity objects.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Tom Kowalski
Ranch Hand

Joined: Feb 17, 2009
Posts: 72
Thanks a lot for the answer ! ^^
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
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

Joined: Oct 01, 2007
Posts: 553
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

Joined: Apr 15, 2010
Posts: 1
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);

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: @NamedNativeQuery and choosing the correct resultClass