• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown

Named query result mapping error

Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I face a problem while using named queries. While using named query and resultset mapping, if I specify all the fields of the class in the resultset mapping it works. If one of the columns is removed, it gives the following error. I use hibernate 3.2.2 version. Appreciate any help

Error message:-
SEVERE: Invalid column name
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query


<resultset name="emailMapping">
<return alias="request" class="vo.Email">
<return-property name="dept" column="dept"/>
<return-property name="email" column="email"/>
<return-property name="emailId" column="emailId"/>

<sql-query name="emailQuery" resultset-ref="emailMapping">
select e.dept AS dept,
e.email AS email,
e.email_Id AS emailId
from SLK_EMAIL e
where request_id = 87373

java code snippet
List results = session.getNamedQuery("emailQuery").list();

Posts: 17347
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, then don't do that. Don't remove a column.

If you need to remove a column, remove it from both the named query and the
result set mapping.

What happens?

Your buns are mine! But you can have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic