-->
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: Column name not found in ResultSet using NamedNativeQuery
PostPosted: Tue Sep 25, 2012 11:38 am 
Newbie

Joined: Thu Jun 02, 2011 1:59 pm
Posts: 3
I am receiving an error from Hibernate when I attempt to query using a NameNativeQuery. The error is:
Code:
SQL Error: 0, SQLState: 42703
The column name id10_0_ was not found in this ResultSet


Here is an example of the Domain Object that I am attempting to query:

Code:
@SqlResultSetMapping(name="getStatusSummary", entities={
  @EntityResult(entityClass=StatusSummary.class, fields={
    @FieldResult(column="id", name="s_id"),
    @FieldResult(column="numThings", name="s_numThings")
   })
})

@NamedNativeQuery(name="getStatusSummary", resultSetMapping="statusSummary",
  query="select s.id as s_id, s.numThings as s_numThings from Status s")

@Entity
public class Status {
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private long id;

  private long numThings;

  // Additional fields

}


Here is the StatusSummary class:

Code:
@Entity
public class StatusSummary implements Serializable {
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private long id;

  private long numThings;
}


Here is the code that generates the error:

Code:
Query query = em.createNamedQuery("getStatusSummary");
List results = query.getResultList();


Error occurs when getResultList() is called.

Anybody have a potential reason why this error would be occurring?


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.