[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3056) Exception with empty resultset in HQL query containing join fetch of collection

Gail Badner (JIRA) noreply at atlassian.com
Wed Jan 9 17:06:55 EST 2008


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

Gail Badner resolved HHH-3056.
------------------------------

      Assignee: Gail Badner
    Resolution: Duplicate

> Exception with empty resultset in HQL query containing join fetch of collection
> -------------------------------------------------------------------------------
>
>                 Key: HHH-3056
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3056
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.2.5
>         Environment: Windows XP sp2, Java 1.6.03, Tomcat 5.5.25
>            Reporter: Tony Lin
>            Assignee: Gail Badner
>         Attachments: object.zip
>
>
> When performing this query on the attached model:
> select subset from com.alphait.domain.snomed.object.SubsetImpl as subset join fetch subset.members as members left join fetch members.parent where subset.id = -1
> We received the following exception:
> org.hibernate.exception.GenericJDBCException: could not perform sequential read of results (forward)
>         at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
>         at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
>         at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
>         at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:398)
>         at org.hibernate.impl.FetchingScrollableResultsImpl.next(FetchingScrollableResultsImpl.java:55)
>         at org.hibernate.impl.FetchingScrollableResultsImpl.first(FetchingScrollableResultsImpl.java:200)
> ...
> Caused by: java.sql.SQLException: Illegal operation on empty result set.
>         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
>         at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:713)
>         at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2850)
>         at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2845)
>         at com.mysql.jdbc.ResultSet.getLong(ResultSet.java:2960)
>         at org.hibernate.type.LongType.get(LongType.java:28)
>         at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
>         at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
>         at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1097)
>         at org.hibernate.loader.Loader.loadSequentialRowsForward(Loader.java:387)
> After investigating the source code, we found two places are problematic:
> 1. org.hibernate.loader.Loader's loadSequentialRowsForward method:
> 			if (resultSet.isAfterLast() ) {
> 				// don't even bother trying to read further
> 				return null;
> 			}
> 			if (resultSet.isBeforeFirst() ) {
> 				resultSet.next();
> 			}
> 	Both isBeforeFirst(), and isAfterLast() returnd false if the resultset is empty, so the code after these statements are executed before next() is called. we added the following lines to fix this problem:
> 			if (resultSet.getRow() < 1) {
> 				return null;
> 			}
> 		
> 2. In org.hibernate.impl.FetchingScrollableResultsImpl's next() method, it aways returns true unless maxPosition is set. Should it be something like the following?
>                Object row = getLoader().loadSequentialRowsForward(
> 				getResultSet(),
> 				getSession(),
> 				getQueryParameters(),
> 				false
> 		);
> 		if (row == null) {
> 			return false;
> 		}
>      .....
> We have not set scroll with other position yet.

-- 
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