-->
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: getSingleResult and "The column position 1 is out of range"
PostPosted: Fri Dec 25, 2009 8:20 pm 
Newbie

Joined: Thu Mar 05, 2009 9:40 am
Posts: 1
Dear all,

I am encountering problems when issuing getSingleResult queries using the Glassfish v3 "hibernate 3.5.0-0.2". These queries work fine if I uninstall the hibernate adon and bundle hibernate 3.3.1.GA with my wars. I'd really like to get into a position where I can use a shared hibernate library, so I have documented the problem here.

The queries are along the lines of
Code:
   Query q = em.createQuery("SELECT COUNT(s) FROM MyTable s");
   Long result = (Long) q.getSingleResult();


and
Code:
   Query query = em.createQuery("SELECT s FROM MyTable s ORDER BY s.id");
   query.setFirstResult(id);
   query.setMaxResults(1);
   MyTable random = (MyTable) query.getSingleResult();


The exception I am seeing is below, when used with (at least) the Java Derby DB. The message is "The column position '1' is out of range. The number of columns for this ResultSet is '0'."

Code:
Caused by: java.sql.SQLException: The column position '1' is out of range.  The number of columns for this ResultSet is '0'.
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.ColumnMetaData.getColumnType(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.setInt(Unknown Source)
        at org.hibernate.loader.Loader.bindLimitParameters(Loader.java:1669)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1594)
        at org.hibernate.loader.Loader.doQuery(Loader.java:694)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:257)
        at org.hibernate.loader.Loader.doList(Loader.java:2232)
        ... 42 more
Caused by: org.apache.derby.client.am.SqlException: The column position '1' is out of range.  The number of columns for this ResultSet is '0'.
        at org.apache.derby.client.am.ColumnMetaData.checkForValidColumnIndex(Unknown Source)
        ... 49 more


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.