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 Named query result mapping error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Named query result mapping error" Watch "Named query result mapping error" New topic
Author

Named query result mapping error

sanker san
Ranch Hand

Joined: Dec 17, 2004
Posts: 52
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

Joined: Feb 05, 2001
Posts: 16622

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Named query result mapping error
 
Threads others viewed
Problem with Sybase stored proc in hibernate
Facing the problem while reterving the resultsets in java from named query function in hibernate
Problem with Oracle CONNECT BY
Sybase stored proc error
Hibernate Newbie - 1 to Many Relation Tutorial
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture