[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3062) Incompleted Collection Returned from Joined Fetch

Tony Lin (JIRA) noreply at atlassian.com
Tue Jan 15 13:31:55 EST 2008


Incompleted Collection Returned from Joined Fetch
-------------------------------------------------

                 Key: HHH-3062
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3062
             Project: Hibernate3
          Issue Type: Bug
          Components: query-hql
    Affects Versions: 3.2.5
         Environment: Windows XP SP2, JDK 1.6_03, MySQL 5, Toncat 5.5.25
            Reporter: Tony Lin
         Attachments: subsets.sql

Executing the following query:

select subset from com.alphait.domain.snomed.object.SubsetImpl as subset join fetch subset.members as members left join fetch members.parent

The members returned after the first subset are not complete, all but the first member are missing.

The classes are attached in HHH-3056. The test data is in the attached file, please load it to a mysql database.

After investigation, the problem seems be in Loader.java's sequentialLoad method:

		try {
			do {
				Object loaded = getRowFromResultSet(
						resultSet,
						session,
						queryParameters,
						getLockModes( queryParameters.getLockModes() ),
						null,
						hydratedObjects,
						loadedKeys,
						returnProxies
					);
				if ( result == null ) {
					result = loaded;
				}
			} 
			while ( keyToRead.equals( loadedKeys[0] ) && resultSet.next() );
		}
		catch ( SQLException sqle ) {
			throw JDBCExceptionHelper.convert(
			        factory.getSQLExceptionConverter(),
			        sqle,
			        "could not perform sequential read of results (forward)",
			        getSQLString()
				);
		}

		initializeEntitiesAndCollections( 
				hydratedObjects, 
				resultSet, 
				session, 
				queryParameters.isReadOnly() 
			);
		session.getPersistenceContext().initializeNonLazyCollections();
		return result;

It will fetch the next subset also, but only the first member, and the member's parent. These three are hydrated, and resolved when initializeEntitiesAndCollections is called.
This makes the members collection to be freezed, and no member can be added.

We put the following:

    key = getKeyFromResultSet(
					        0,
							persisters[0],
							null,
							resultSet,
							session
						);
				
    if (!keyToRead.equals(key)) { // we are done, no moving forward
	break;
    }
			
before calling getRowFromResultSet(). This temporarily solved the problem for us.

Also this kind of query cannot have order by containing only the members'  properties as it will return rows not ordered by Subset's ID. I think the HQL query parser should not permit this. 	

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