Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Named query result mapping error

 
sanker san
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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


configuration

<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"/>
</return>
</resultset>

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



java code snippet
List results = session.getNamedQuery("emailQuery").list();
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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?

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic