[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3865) org.hibernate.Query iterate() ignores query's setCacheMode setting

Erel Magnus (JIRA) noreply at atlassian.com
Fri Apr 17 10:05:17 EDT 2009


org.hibernate.Query iterate() ignores query's setCacheMode setting
------------------------------------------------------------------

                 Key: HHH-3865
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3865
             Project: Hibernate Core
          Issue Type: Bug
         Environment: Postgresql, core 3.3.1GA
            Reporter: Erel Magnus
            Priority: Critical


The code below allways takes data from cache even though it shouldn't.

org.hibernate.Query query = getSession().getNamedQuery("X");
query.setCacheMode(CacheMode.IGNORE);
return query.iterate();

After debugging for a bit, I found that what happens is that:
1. The query selects only the ID
2. next() method of iterator allways return proxy
3. Accessing the proxy loads the object, and does it according to the session settings and not the query settings. In the above example it will load it from the cache.

The documentation states:

Override the current session cache mode, just for this query.

So from my understanding this includes also iterators that are part of the query.


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