0 Replies Latest reply on Jun 8, 2006 8:22 AM by andy

    Hibernate query hint org.hibernate.readOnly not working?

    andy Newbie

      we encounter following behaviour while optimizing our ejb3 application:

      - we have an Entity X with 2 collections of other entities
      - loading of a big list of X (> 8000) takes ca. 3 s
      - 2 subsequent loads of smaller lists of other entites in the same transaction take also 1-2 s
      - the hibernate log shows dirty checking of collections of all X in the big list even if query hint readOnly is set, times are the same
      - if not Entity X is loaded but only 2 fields thereof the subsequent loads take < 100ms

      we changed this only for testing - we have to load the complete entity in the real system. are there any other ways or ideas how to avoid the time consuming dirty checking for read only methods? thanks in advance!


      the profiling output:

      with query hint readOnly:
      09:53:43,536 INFO [STDOUT] getStreets: 3142 ms
      09:53:45,365 INFO [STDOUT] getZipCodes: 1829 ms
      09:53:48,930 INFO [STDOUT] getUIStateBar search version count 1: 1829 ms
      09:53:49,117 INFO [STDOUT] getUIView: 8770 ms

      without query hint readOnly:
      09:58:14,540 INFO [STDOUT] getStreets: 2987 ms
      09:58:16,416 INFO [STDOUT] getZipCodes: 1876 ms
      09:58:19,528 INFO [STDOUT] getUIStateBar search version count 1: 1579 ms
      09:58:19,716 INFO [STDOUT] getUIView: 8226 ms

      using an extra object in query and not loading 8000 Entity X objects:
      10:00:08,518 INFO [STDOUT] getStreets: 1189 ms
      10:00:08,596 INFO [STDOUT] getZipCodes: 78 ms
      10:00:08,658 INFO [STDOUT] getUIStateBar search version count 1: 31 ms
      10:00:08,846 INFO [STDOUT] getUIView: 1564 ms