File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Error in named native query (Invalid Column Name) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error in named native query (Invalid Column Name)" Watch "Error in named native query (Invalid Column Name)" New topic
Author

Error in named native query (Invalid Column Name)

Dominique Von Hofcheirken
Greenhorn

Joined: Oct 02, 2009
Posts: 6
Hi There,

I am trying to get a native query work. I put it in a mapping file:



The code to have it is the following:



Strangely, I got the exception:



Any ideas??
Many Thanks in advance.
Andreas Erber
Greenhorn

Joined: Oct 03, 2009
Posts: 20
Hi Dominique,

how is someone supposed to solve a problem with a query on a table if the table layout is unknown? Sorry, I can't do that, my crystal ball is currently in repair...

Post some info on the table you are querying or a mapping file that produces the query. Then, maybe someone can help...

CU
Froestel
Dominique Von Hofcheirken
Greenhorn

Joined: Oct 02, 2009
Posts: 6
Hi Andreas,

you're right!:P
However, I solved the issue.
The problem is that Hibernate tries to retrieve all mapped columns specified for DataValues objects, even if I specified only to get tow of them in the following named query in the mapping document:



Then the strange error:
could not read column value from result set: PK1_8_0_; Invalid column name

Then, I created a new mapping document and a new mapped object to exactly fit the query:



Do you think it's a normal behavior?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in named native query (Invalid Column Name)
 
Similar Threads
Problem in SP Calling using Hibernate
Calling stored Procedure using hibernate
problem using hibernate and stored procedures for reading portion of data from database
Problem with named queries
Executing stored procedures in hibernate