Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help with nativeQuery  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have tried to do the query using expression constructors and jpql, but jpql does not support subqueryes and then, i am trying to do with nativeQuery. It's possible?

I'm getting an error message. Would anyone know why?

The query is as follows:




The Query at the Console is



It runs in mysql and returns results correctly, but in the class I'm testing the following error occurs:

 
Ranch Hand
Posts: 1686
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, does the column "codigo" exist in the table  Usuario in the mySQL database? Or, does the codigo attribute in the Usuario entity mapped to another name in the table?
 
RafaelCarvalho Moreira
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my table Usuario and the column "codigo" exist in the table.

 
Himai Minh
Ranch Hand
Posts: 1686
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe, try to run a simple native query like "select codigo from Usuario " and see if  the column can be found.
 
RafaelCarvalho Moreira
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have done your advice and occured an error .





 
Himai Minh
Ranch Hand
Posts: 1686
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this in your class:
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!