[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-2545) Query cache dosen't work with queries that return Collections

Emmanuel Bernard (JIRA) noreply at atlassian.com
Mon Apr 9 09:37:06 EDT 2007


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

Emmanuel Bernard resolved HHH-2545.
-----------------------------------

    Resolution: Duplicate

Yes this was a bug in annotations. It is fixed now

> Query cache dosen't work with queries that return Collections
> -------------------------------------------------------------
>
>                 Key: HHH-2545
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2545
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.3
>         Environment: Windows XP, jdk1.5.0_06 
>            Reporter: Jacek Halat
>            Priority: Critical
>         Attachments: QueryCacheBag.zip
>
>
> If :
> * second level cache is enabled 
> * query cache is enabled
> * query return collection of objects
> first query execution return collection of objects, but second, third etc, call returns.... Collection with null element (collection size is corect, but collection contains onlu null elements instead of objects).
> I do some investigation and found, that if query cache is enabled, StandardQueryCache.put() method is caled. This method store cachable object in queryCache. Cachable is List with timestamp as first element and disassembled Entities as rest elements.
> If List contains only 1 element this line is called:
> 				if ( returnTypes.length==1 ) {
> 					cacheable.add( returnTypes[0].disassemble( result.get(i), session, null ) );
> 				}
> 				else {
> 					cacheable.add( TypeFactory.disassemble( (Object[]) result.get(i), returnTypes, null, session, null ) );
> 				}
> if query returns collection, CollectionType.disassemble() is called, this methods looks like:
> 	public Serializable disassemble(Object value, SessionImplementor session, Object owner)
> 			throws HibernateException {
> 		//remember the uk value
> 		
> 		//This solution would allow us to eliminate the owner arg to disassemble(), but
> 		//what if the collection was null, and then later had elements added? seems unsafe
> 		//session.getPersistenceContext().getCollectionEntry( (PersistentCollection) value ).getKey();
> 		
> 		final Serializable key = getKeyOfOwner(owner, session);
> 		if (key==null) {
> 			return null;
> 		}
> 		else {
> 			return getPersister(session)
> 					.getKeyType()
> 					.disassemble( key, session, owner );
> 		}
> 	}
> This method is called with owner=null, and value=first element from collection. 
> IF cource because owner==null getKeyOfOwner returns null and null is stored in queryCache!!!!!!!!!!! (and no warning or error is logged or exception is thrown), so user can think, that query is corrcectly cached.
> Now when query is executed second time, cached collection is returned, but it contains only null as value!!!!!
> JUnit test included (QueryCacheBagTest)
> For me this is critical bug, because it's impossible to work with qached query in clustered environment, so system performance is now very, very low.
> I hope that this issue wil be resolved as soon possible.

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