[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4738) getSingleResult returning SQLException in DerbyDialect

Samuel Halliday (JIRA) noreply at atlassian.com
Sat Dec 26 20:35:29 EST 2009


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Samuel Halliday updated HHH-4738:
---------------------------------

    Attachment: WebJpa.zip

I've attached a failing testcase.

This has been adapted from the NetBeans bundled "WebJPA Sample" - demonstrating simple JPA SQL and @Entity persistence. I've changed the ListPersonServlet so that it performs two different types of getSingleResult queries (it's picking a random entity, not listing all of them).

Obviously, the second Query never gets called because the first one always throws up an Exception - it's included to insure that the fix is complete.

There is no need to add any entries into the database in order to observe the exception.

This bug also manifests itself if em.getTransaction()... is used instead of the JTA.

Works fine if I use Hibernate 3.3.1, but not if I use Hibernate 3.5 Beta 2.

> getSingleResult returning SQLException in DerbyDialect
> ------------------------------------------------------
>
>                 Key: HHH-4738
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4738
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.5.0-Beta-2
>         Environment: hibernate 3.5.0-0.2, Glassfish v3, Derby
>            Reporter: Samuel Halliday
>         Attachments: WebJpa.zip
>
>
> I am encountering problems when issuing getSingleResult queries using the Glassfish v3 "hibernate 3.5.0-0.2". These queries work fine if I use hibernate 3.3.1.GA, or a PostgreSQL backend/dialect. Something between 3.3.1 and 3.5 has therefore introduced this bug.
> The queries are along the lines of
> [code]
> 	Query q = em.createQuery("SELECT COUNT(s) FROM MyTable s");
> 	Long result = (Long) q.getSingleResult();
> [/code]
> 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();
> [/code]
> 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
> [/code]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list