wood burning stoves*
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 Android Security Essentials Live Lessons this week in the Android 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);

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @NamedNativeQuery and choosing the correct resultClass
 
Similar Threads
JPA and mapping result sets to POJO:s
How to call stored procedure from Entity Manager if there is out parameter in stored procedure.
Stored procedures JPA and mappings
Hibernate second level cache questions
How to map returned cursor to a POJO / Bean in Hibernate?