-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Result set mapping for NamedNativeQuery is throwing exceptio
PostPosted: Sun Nov 11, 2007 8:05 am 
Newbie

Joined: Sun Nov 11, 2007 7:53 am
Posts: 2
Hi All,
I think this is some configuration problem but I am not able to get resultSetMapping working with NamedNativeQuery. Hibernate is not using the result set mapping provided by me. Instead it is using the default mapping and throwing exception.

Please see below all the config/code and exception details.

Regards,
Anshaj

Hibernate version:
hibernate-3.2

Mapping documents:
@Entity
@Table(name = "city")
@SecondaryTable(name="street")
@NamedNativeQuery(name = "city&street", query = "select city.city_Id as cid, city.name as cname, "
+ " street.street_id , street.name as sname, street.city_id as sid "
+ "from city city, street street where city.city_id = street.city_id", resultSetMapping = "joinMapping")
@SqlResultSetMapping(name = "joinMapping", entities = {
@EntityResult(entityClass = City.class, fields = {
@FieldResult(name = "cityID", column = "cid"),
@FieldResult(name = "name", column = "cname"), }),
@EntityResult(entityClass = Street.class, fields = {
@FieldResult(name = "streetID", column = "street_id"),
@FieldResult(name = "name", column = "sname"),
@FieldResult(name = "cityID", column = "sid") }) })

Code between sessionFactory.openSession() and session.close():

session.getNamedQuery("city&street").list();

Full stack trace of any exception that occurs:

Caused by: org.postgresql.util.PSQLException: The column name city1_1_1_ was not found in this ResultSet.
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.findColumn(AbstractJdbc2ResultSet.java:2465)
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:2306)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:103)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 7 more


Name and version of the database you are using:

Name: Postgresql
Version: 8.1

The generated SQL (show_sql=true):

select city.city_Id as cid, city.name as cname, street.street_id , street.name as sname, street.city_id as sid from city city, street street where city.city_id = street.city_id

Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.