Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in named native query (Invalid Column Name)

 
Dominique Von Hofcheirken
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!