Changeset 3808 for branches/2.4-stable


Ignore:
Timestamp:
Oct 8, 2007, 11:25:37 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #794: Long query may cause session to timeout

Location:
branches/2.4-stable/src/core/net/sf/basedb/core
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4-stable/src/core/net/sf/basedb/core/AnnotationRestriction.java

    r3679 r3808  
    105105    throws BaseException
    106106  {
     107    SessionControl sc = dc.getSessionControl();
    107108    String valueTable = null;
    108109    if (valueType == Type.INT)
     
    168169    {
    169170      if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    170       List<Object[]> twoIds = HibernateUtil.loadList(Object[].class, sqlQuery);
     171      List<Object[]> twoIds = HibernateUtil.loadList(Object[].class, sqlQuery, sc);
    171172      StringBuilder annotationSets = new StringBuilder("0");
    172173      StringBuilder annotations = new StringBuilder("0");
     
    192193        sqlQuery.addScalar("annotationset_id", org.hibernate.Hibernate.INTEGER);
    193194        if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    194         List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery);
     195        List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc);
    195196        annotationSets = new StringBuilder(annotationSetIds);
    196197        for (Integer id : ids)
     
    204205    {
    205206      if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    206       List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery);
     207      List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc);
    207208      StringBuilder annotationSets = new StringBuilder("0");
    208209      for (Integer id : ids)
  • branches/2.4-stable/src/core/net/sf/basedb/core/Application.java

    r3679 r3808  
    3333import java.util.Calendar;
    3434import java.util.GregorianCalendar;
     35import java.util.HashSet;
    3536import java.util.Map;
    3637import java.util.HashMap;
     
    3839import java.util.Iterator;
    3940import java.util.Random;
     41import java.util.Set;
    4042import java.util.Timer;
    4143import java.util.TimerTask;
     
    453455 
    454456        // Adding a task that cleans the session control cache at regular intervale
    455         long milliSeconds = 60*1000*sessionCacheTimeout;
     457        long milliSeconds = 60 * 1000 * sessionCacheTimeout;
    456458        getScheduler().schedule(new SessionControlCacheCleaner(), milliSeconds, milliSeconds, false);
    457459       
     
    840842  private static void cleanSessionControlCache(boolean force)
    841843  {
     844    if (!force)
     845    {
     846      // Ping all sessioncontrols in the pingers set
     847      for (Pinger p : pingers)
     848      {
     849        p.ping();
     850      }
     851    }
     852   
    842853    synchronized(sessionCache)
    843854    {
    844855      Iterator<SessionControl> i = sessionCache.values().iterator();
    845856      long now = System.currentTimeMillis();
     857      long timout = 60 * 1000 * sessionCacheTimeout;
    846858      while (i.hasNext())
    847859      {
    848860        SessionControl sc = i.next();
    849         if (force || ((now - sc.getLastAccess()) > 60*1000*sessionCacheTimeout))
     861        if (force || ((now - sc.getLastAccess()) > timout))
    850862        {
    851863          log.info("cleanSessionControlCache: Remove[ID="+sc.getId()+"]");
     
    854866            if (sc.isLoggedIn()) sc.logout();
    855867          }
    856           catch (BaseException ex)
     868          catch (Throwable t)
    857869          {
    858             log.error("Exception during cleanSessionControlCache", ex);
     870            log.error("Exception during cleanSessionControlCache", t);
    859871          }
    860872          finally
    861873          {
     874            sc.close();
    862875            i.remove();
    863876          }
     
    953966  }
    954967 
     968  private static Set<Pinger> pingers =
     969    Collections.synchronizedSet(new HashSet<Pinger>());
     970 
     971  /**
     972    Create a new <code>Pinger</code> object that is used
     973    to keep a session control alive.
     974   
     975    @param sc The SessionControl that the pinger should protect
     976    @return A pinger object
     977    @since 2.4.5
     978  */
     979  public static Pinger newPinger(SessionControl sc)
     980  {
     981    Pinger p = new Pinger(sc);
     982    pingers.add(p);
     983    return p;
     984  }
     985 
     986  private static void stopPinger(Pinger p)
     987  {
     988    pingers.remove(p);
     989  }
     990 
     991  /**
     992    A <code>Pinger</code> is an object that is used to protect another
     993    object from timing out by automatically pinging it. This can for
     994    example be used by a client to override the timeout for SessionControl
     995    items.
     996   
     997    @since 2.4.5
     998  */
     999  public static class Pinger
     1000  {
     1001    private final SessionControl sc;
     1002    private Pinger(SessionControl sc)
     1003    {
     1004      this.sc = sc;
     1005    }
     1006    /**
     1007      Ping the SessionControl by updating the last access time:
     1008      {@link SessionControl#updateLastAccess()}
     1009    */
     1010    public void ping()
     1011    {
     1012      if (!sc.isClosed()) sc.updateLastAccess();
     1013    }
     1014    /**
     1015      Stop this pinger.
     1016    */
     1017    public void stop()
     1018    {
     1019      Application.stopPinger(this);
     1020    }
     1021  }
     1022 
    9551023}
  • branches/2.4-stable/src/core/net/sf/basedb/core/BasicItem.java

    r3679 r3808  
    251251    query.setInteger("toType", this.getType().getValue());
    252252    Set<ItemProxy> using = new TreeSet<ItemProxy>();
    253     for (Object[] u : HibernateUtil.loadList(Object[].class, query))
     253    for (Object[] u : HibernateUtil.loadList(Object[].class, query, getSessionControl()))
    254254    {
    255255      using.add(new ItemProxy((Integer)u[0], Item.fromValue((Integer)u[1])));
     
    268268  protected void addUsingItems(Set<ItemProxy> using, Item itemType, org.hibernate.Query query)
    269269  {
    270     for (Integer itemId : HibernateUtil.loadList(Integer.class, query))
     270    for (Integer itemId : HibernateUtil.loadList(Integer.class, query, getSessionControl()))
    271271    {
    272272      using.add(new ItemProxy(itemId, itemType));
     
    282282  protected void addUsingItems(Set<ItemProxy> using, org.hibernate.Query query)
    283283  {
    284     for (BasicData item : HibernateUtil.loadList(BasicData.class, query))
     284    for (BasicData item : HibernateUtil.loadList(BasicData.class, query, getSessionControl()))
    285285    {
    286286      using.add(new ItemProxy(item.getId(), Item.fromDataClass(item.getClass())));
  • branches/2.4-stable/src/core/net/sf/basedb/core/BioAssaySet.java

    r3679 r3808  
    12091209  {
    12101210    DbControl dc = getDbControl();
     1211    SessionControl sc = dc.getSessionControl();
    12111212   
    12121213    // 1. Find all child bioassaysets recursively
     
    12271228    */
    12281229    query.setParameterList("basList", all);
    1229     List<DataCubeData> possibleCubes = HibernateUtil.loadList(DataCubeData.class, query);
     1230    List<DataCubeData> possibleCubes = HibernateUtil.loadList(DataCubeData.class, query, sc);
    12301231   
    12311232    // 2b. Among the found data cubes, find those that are also used by other bioassaysets
     
    12421243      query.setParameterList("basList", all);
    12431244      query.setParameterList("possibleCubes", possibleCubes);
    1244       possibleCubes.removeAll(HibernateUtil.loadList(DataCubeData.class, query));
     1245      possibleCubes.removeAll(HibernateUtil.loadList(DataCubeData.class, query, sc));
    12451246     
    12461247 
     
    12791280      query.setParameterList("deletedCubes", possibleCubes);
    12801281    }
    1281     List<DataCubeLayerData> possibleLayers = HibernateUtil.loadList(DataCubeLayerData.class, query);
     1282    List<DataCubeLayerData> possibleLayers = HibernateUtil.loadList(DataCubeLayerData.class, query, sc);
    12821283   
    12831284    if (possibleLayers.size() > 0)
     
    12941295      query.setParameterList("basList", all);
    12951296      query.setParameterList("possibleLayers", possibleLayers);
    1296       possibleLayers.removeAll(HibernateUtil.loadList(DataCubeLayerData.class, query));
     1297      possibleLayers.removeAll(HibernateUtil.loadList(DataCubeLayerData.class, query, sc));
    12971298     
    12981299      // 3c. Delete data from the remaining layers
     
    13301331      query.setParameterList("deletedCubes", possibleCubes);
    13311332    }
    1332     List<DataCubeFilterData> possibleFilters = HibernateUtil.loadList(DataCubeFilterData.class, query);
     1333    List<DataCubeFilterData> possibleFilters = HibernateUtil.loadList(DataCubeFilterData.class, query, sc);
    13331334   
    13341335    if (possibleFilters.size() > 0)
     
    13451346      query.setParameterList("basList", all);
    13461347      query.setParameterList("possibleFilters", possibleFilters);
    1347       possibleFilters.removeAll(HibernateUtil.loadList(DataCubeFilterData.class, query));
     1348      possibleFilters.removeAll(HibernateUtil.loadList(DataCubeFilterData.class, query, sc));
    13481349
    13491350      // 4c. Delete data from the remaining layers
     
    13811382      query.setParameterList("deletedCubes", possibleCubes);
    13821383    }
    1383     List<DataCubeExtraValueData> possibleExtraValues = HibernateUtil.loadList(DataCubeExtraValueData.class, query);
     1384    List<DataCubeExtraValueData> possibleExtraValues = HibernateUtil.loadList(DataCubeExtraValueData.class, query, sc);
    13841385   
    13851386    if (possibleExtraValues.size() > 0)
     
    13961397      query.setParameterList("basList", all);
    13971398      query.setParameterList("possibleExtraValues", possibleExtraValues);
    1398       possibleExtraValues.removeAll(HibernateUtil.loadList(DataCubeExtraValueData.class, query));
     1399      possibleExtraValues.removeAll(HibernateUtil.loadList(DataCubeExtraValueData.class, query, sc));
    13991400     
    14001401      // 5c. Delete data from the remaining extra values
     
    14301431    }
    14311432    findChildren.setEntity("parent", parent);
    1432     List<BioAssaySetData> children = HibernateUtil.loadList(BioAssaySetData.class, findChildren);
     1433    List<BioAssaySetData> children = HibernateUtil.loadList(BioAssaySetData.class, findChildren, null);
    14331434    for (BioAssaySetData child : children)
    14341435    {
  • branches/2.4-stable/src/core/net/sf/basedb/core/DataQuery.java

    r3679 r3808  
    8282    enableFilters(dc);
    8383    long totalCount = -1;
     84    SessionControl sc = dc.getSessionControl();
    8485
    8586    // Load the total count if it is requested
     
    9091   
    9192    // Load the results
    92     ScrollIterator<I> result = HibernateUtil.loadIterator(dataClass,  getMainHqlQuery(dc));
     93    ScrollIterator<I> result =
     94      HibernateUtil.loadIterator(dataClass,  getMainHqlQuery(dc), sc);
    9395    disableFilters(dc);
    9496    return new DataResultIterator<I>(result, dc.getSessionControl(),
  • branches/2.4-stable/src/core/net/sf/basedb/core/DiskUsageStatistics.java

    r3675 r3808  
    237237    private void loadDiskUsage(org.hibernate.Query query)
    238238    {
    239       List<Object[]> du = HibernateUtil.loadList(Object[].class, query);
     239      List<Object[]> du = HibernateUtil.loadList(Object[].class, query, null);
    240240      for (Object[] row : du)
    241241      {
  • branches/2.4-stable/src/core/net/sf/basedb/core/Group.java

    r3679 r3808  
    147147      {
    148148        query.setParameterList("groups", allGroups, org.hibernate.Hibernate.INTEGER);
    149       } while (allGroups.addAll(HibernateUtil.loadList(Integer.class, query)));
     149      } while (allGroups.addAll(HibernateUtil.loadList(Integer.class, query, null)));
    150150    }
    151151    return allGroups;
  • branches/2.4-stable/src/core/net/sf/basedb/core/HibernateUtil.java

    r3679 r3808  
    14491449    @param clazz The list should contain objects of this class
    14501450    @param query The query to execute
     1451    @param sc A optional SessionControl that is automatically protected from
     1452      timeouts during the time the query is running
    14511453  */
    14521454  @SuppressWarnings({"unchecked"})
    1453   static <T> List<T> loadList(Class<T> clazz, Query query)
     1455  static <T> List<T> loadList(Class<T> clazz, Query query, SessionControl sc)
    14541456    throws BaseException
    14551457  {
    14561458    assert query != null : "query == null";
    1457     try
    1458     {
     1459    Application.Pinger pinger = null;
     1460    try
     1461    {
     1462      if (sc != null) pinger = Application.newPinger(sc);
    14591463      return (List<T>)query.list();
    14601464    }
     
    14621466    {
    14631467      throw new BaseException(ex);
     1468    }
     1469    finally
     1470    {
     1471      if (pinger != null) pinger.stop();
    14641472    }
    14651473  }
     
    14691477    @param clazz The iterator returns objects of this class
    14701478    @param query The query to execute
    1471   */
    1472   static <T> ScrollIterator<T> loadIterator(Class<T> clazz, Query query)
     1479    @param sc A optional SessionControl that is automatically protected from
     1480      timeouts during the time the query is running
     1481  */
     1482  static <T> ScrollIterator<T> loadIterator(Class<T> clazz, Query query, SessionControl sc)
    14731483    throws BaseException
    14741484  {
    14751485    assert query != null : "query == null";
    1476     try
    1477     {
     1486    Application.Pinger pinger = null;
     1487    try
     1488    {
     1489      if (sc != null) pinger = Application.newPinger(sc);
     1490      Thread.sleep(5000);
    14781491      ScrollableResults result = query.scroll(ScrollMode.FORWARD_ONLY);
    14791492      return new ScrollIterator<T>(clazz, result);
     
    14821495    {
    14831496      throw new BaseException(ex);
     1497    }
     1498    finally
     1499    {
     1500      if (pinger != null) pinger.stop();
    14841501    }
    14851502  }
  • branches/2.4-stable/src/core/net/sf/basedb/core/InternalJobQueue.java

    r3679 r3808  
    253253      query.setInteger("status", Job.Status.WAITING.getValue());
    254254      query.setInteger("type", Job.Type.RUN_PLUGIN.getValue());
    255       List<JobData> jobs = HibernateUtil.loadList(JobData.class, query);
     255      List<JobData> jobs = HibernateUtil.loadList(JobData.class, query, null);
    256256     
    257257      log.info("Found " + jobs.size() + " jobs waiting for execution");
  • branches/2.4-stable/src/core/net/sf/basedb/core/ItemKey.java

    r3679 r3808  
    157157        WHERE NOT sd.itemKey IS NULL
    158158      */
    159       Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query));
     159      Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
    160160      if (used.size() == 0) used.add(0);
    161161      query = HibernateUtil.getPredefinedQuery(session, "SELECT_UNUSED_ITEMKEYS");
     
    165165      */
    166166      query.setParameterList("used", used, org.hibernate.Hibernate.INTEGER);
    167       List<ItemKeyData> unused = HibernateUtil.loadList(ItemKeyData.class, query);
     167      List<ItemKeyData> unused = HibernateUtil.loadList(ItemKeyData.class, query, null);
    168168      for (ItemKeyData ik : unused)
    169169      {
     
    363363      */
    364364      query.setInteger("numPermissions", numPermissions);
    365       List<Integer> candidates = HibernateUtil.loadList(Integer.class, query);
     365      List<Integer> candidates = HibernateUtil.loadList(Integer.class, query, null);
    366366      if (candidates.size() > 0 && numPermissions > 0 && userPermissions != null)
    367367      {
     
    385385        query.setParameterList("candidates", candidates, org.hibernate.Hibernate.INTEGER);
    386386        query.setInteger("numPermissions", numPermissions);
    387         candidates = HibernateUtil.loadList(Integer.class, query);
     387        candidates = HibernateUtil.loadList(Integer.class, query, null);
    388388      }
    389389     
     
    403403        query.setInteger("numPermissions", numPermissions);
    404404        query.setParameterList("candidates", candidates, org.hibernate.Hibernate.INTEGER);
    405         candidates = HibernateUtil.loadList(Integer.class, query);       
     405        candidates = HibernateUtil.loadList(Integer.class, query, null);       
    406406      }
    407407
     
    428428        query.setParameterList("candidates", candidates, org.hibernate.Hibernate.INTEGER);
    429429        query.setInteger("numPermissions", numPermissions);
    430         candidates = HibernateUtil.loadList(Integer.class, query);
     430        candidates = HibernateUtil.loadList(Integer.class, query, null);
    431431      }
    432432 
  • branches/2.4-stable/src/core/net/sf/basedb/core/ItemQuery.java

    r3679 r3808  
    9090  {
    9191    enableFilters(dc);
     92    SessionControl sc = dc.getSessionControl();
    9293   
    93     List<? extends BasicData> result = HibernateUtil.loadList(dataClass, getMainHqlQuery(dc));
     94    List<? extends BasicData> result = HibernateUtil.loadList(dataClass, getMainHqlQuery(dc), sc);
    9495    long totalCount = result.size();
    9596   
     
    115116    enableFilters(dc);
    116117    long totalCount = -1;
     118    SessionControl sc = dc.getSessionControl();
    117119   
    118120    // Load the total count if it is requested
     
    122124    }
    123125
    124     ScrollIterator<? extends BasicData> result = HibernateUtil.loadIterator(dataClass, getMainHqlQuery(dc));
     126    ScrollIterator<? extends BasicData> result =
     127      HibernateUtil.loadIterator(dataClass, getMainHqlQuery(dc), sc);
    125128    disableFilters(dc);
    126129    return new ItemResultIterator<I>(result, dc, itemClass, totalCount);
  • branches/2.4-stable/src/core/net/sf/basedb/core/Keyring.java

    r3679 r3808  
    323323      */
    324324      query.setInteger("userId", userId);
    325       temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query));
     325      temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
    326326      roles = Collections.unmodifiableSet(temp);
    327327    }
     
    350350      */
    351351      query.setInteger("userId", userId);
    352       temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query));
     352      temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
    353353     
    354354      query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_GROUP_ID_FOR_USER");
     
    375375        {
    376376          query.setParameterList("groups", temp, org.hibernate.Hibernate.INTEGER);
    377         } while (temp.addAll(HibernateUtil.loadList(Integer.class, query)));
     377        } while (temp.addAll(HibernateUtil.loadList(Integer.class, query, null)));
    378378        // repeat until no more new groups are found
    379379      }
     
    406406      */
    407407      query.setInteger("userId", userId);
    408       for (Integer i : HibernateUtil.loadList(Integer.class, query))
     408      for (Integer i : HibernateUtil.loadList(Integer.class, query, null))
    409409      {
    410410        temp.put(i, ALL_ITEM);
     
    419419      */
    420420      query.setInteger("userId", userId);
    421       for (UserProjects up : HibernateUtil.loadList(UserProjects.class, query))
     421      for (UserProjects up : HibernateUtil.loadList(UserProjects.class, query, null))
    422422      {
    423423        Integer i = temp.get(up.getProjectId());
     
    435435        */
    436436        query.setParameterList("groups", groups, org.hibernate.Hibernate.INTEGER);
    437         for (GroupProjects gp : HibernateUtil.loadList(GroupProjects.class, query))
     437        for (GroupProjects gp : HibernateUtil.loadList(GroupProjects.class, query, null))
    438438        {
    439439          Integer i = temp.get(gp.getProjectId());
     
    471471        */
    472472        query.setParameterList("groups", groups, org.hibernate.Hibernate.INTEGER);
    473         temp.addAll(HibernateUtil.loadList(Integer.class, query));
     473        temp.addAll(HibernateUtil.loadList(Integer.class, query, null));
    474474       
    475475        // Get the users that have a quota group among the same groups
     
    481481        */
    482482        query.setParameterList("groups", groups, org.hibernate.Hibernate.INTEGER);
    483         temp.addAll(HibernateUtil.loadList(Integer.class, query));
     483        temp.addAll(HibernateUtil.loadList(Integer.class, query, null));
    484484      }
    485485     
     
    498498        */
    499499        query.setInteger("projectId", projectId);
    500         temp.addAll(HibernateUtil.loadList(Integer.class, query));
     500        temp.addAll(HibernateUtil.loadList(Integer.class, query, null));
    501501       
    502502        // Get groups that are direct members of the active project
     
    509509        query.setInteger("projectId", projectId);
    510510        // Load the direct groups and subgroups
    511         Set<Integer> projectGroups = Group.getGroupsRecursive(session, HibernateUtil.loadList(Integer.class, query));
     511        Set<Integer> projectGroups = Group.getGroupsRecursive(session, HibernateUtil.loadList(Integer.class, query, null));
    512512
    513513        // Load users that are members of the project groups
     
    541541      */
    542542      query.setInteger("userId", userId);
    543       List<KeyPermission> keys = HibernateUtil.loadList(KeyPermission.class, query);
     543      List<KeyPermission> keys = HibernateUtil.loadList(KeyPermission.class, query, null);
    544544
    545545      // Load keys shared to any of the groups where the user is a member
     
    553553        */
    554554        query.setParameterList("groups", groups, org.hibernate.Hibernate.INTEGER);
    555         keys.addAll(HibernateUtil.loadList(KeyPermission.class, query));
     555        keys.addAll(HibernateUtil.loadList(KeyPermission.class, query, null));
    556556      }
    557557
     
    612612      */
    613613      query.setInteger("userId", userId);
    614       List<RoleKeys> roleKeys = HibernateUtil.loadList(RoleKeys.class, query);
     614      List<RoleKeys> roleKeys = HibernateUtil.loadList(RoleKeys.class, query, null);
    615615     
    616616      // Copy the permission from the list to the array
     
    665665      */
    666666      query.setInteger("pluginId", pluginId);
    667       List<PluginKeys> keys = HibernateUtil.loadList(PluginKeys.class, query);
     667      List<PluginKeys> keys = HibernateUtil.loadList(PluginKeys.class, query, null);
    668668     
    669669      // Copy the permissions from the list to the array
     
    701701      */
    702702      query.setInteger("projectId", projectId);
    703       List<ProjectKeys> keys = HibernateUtil.loadList(ProjectKeys.class, query);
     703      List<ProjectKeys> keys = HibernateUtil.loadList(ProjectKeys.class, query, null);
    704704
    705705      // Copy the permissions from the List to the array
  • branches/2.4-stable/src/core/net/sf/basedb/core/PluginDefinition.java

    r3679 r3808  
    317317    query.setParameterList("projectKeys", projectKeys, org.hibernate.Hibernate.INTEGER);
    318318 
    319     List<Object> pluginCount = HibernateUtil.loadList(Object.class, query);
     319    List<Object> pluginCount = HibernateUtil.loadList(Object.class, query, dc.getSessionControl());
    320320    Map<Plugin.MainType, Integer> result = new HashMap<Plugin.MainType, Integer>(5);
    321321    for (Object cnt : pluginCount)
     
    11291129    org.hibernate.Query query = HibernateUtil.createQuery(
    11301130      getDbControl().getHibernateSession(), "SELECT pt FROM PluginTypeData pt");
    1131     List<PluginTypeData> types = HibernateUtil.loadList(PluginTypeData.class, query);
     1131    List<PluginTypeData> types = HibernateUtil.loadList(PluginTypeData.class, query, null);
    11321132
    11331133    for (PluginTypeData pt : types)
  • branches/2.4-stable/src/core/net/sf/basedb/core/Project.java

    r3679 r3808  
    393393      */
    394394      query.setInteger("projectId", this.getId());
    395       projectKeys = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query));
     395      projectKeys = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, sc));
    396396     
    397397      include.remove(Include.OTHERS);
     
    458458      FROM net.sf.basedb.core.data.ShareableData item
    459459    */
    460     List<ShareableData> inProject = HibernateUtil.loadList(ShareableData.class, query);
     460    List<ShareableData> inProject = HibernateUtil.loadList(ShareableData.class, query, sc);
    461461    List<Shareable> items = new ArrayList<Shareable>(inProject.size());
    462462
  • branches/2.4-stable/src/core/net/sf/basedb/core/ProjectKey.java

    r3679 r3808  
    142142        WHERE NOT sd.projectKey IS NULL
    143143      */
    144       Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query));
     144      Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
    145145      if (used.size() == 0) used.add(0);
    146146      query = HibernateUtil.getPredefinedQuery(session, "SELECT_UNUSED_PROJECTKEYS");
     
    150150      */
    151151      query.setParameterList("used", used, org.hibernate.Hibernate.INTEGER);
    152       List<ProjectKeyData> unused = HibernateUtil.loadList(ProjectKeyData.class, query);
     152      List<ProjectKeyData> unused = HibernateUtil.loadList(ProjectKeyData.class, query, null);
    153153      for (ProjectKeyData pk : unused)
    154154      {
     
    307307      */
    308308      query.setInteger("numPermissions", numPermissions);
    309       List<Integer> candidates = HibernateUtil.loadList(Integer.class, query);
     309      List<Integer> candidates = HibernateUtil.loadList(Integer.class, query, null);
    310310      if (candidates.size() > 0)
    311311      {
     
    330330        query.setParameterList("candidates", candidates, org.hibernate.Hibernate.INTEGER);
    331331        query.setInteger("numPermissions", numPermissions);
    332         candidates = HibernateUtil.loadList(Integer.class, query);
     332        candidates = HibernateUtil.loadList(Integer.class, query, null);
    333333      }
    334334      if (candidates.size() == 0)
  • branches/2.4-stable/src/core/net/sf/basedb/core/RawBioAssay.java

    r3748 r3808  
    783783      */
    784784      query.setInteger("arrayDesign", design.getId());
    785       ScrollIterator<FeatureData> si = HibernateUtil.loadIterator(FeatureData.class, query);
     785      ScrollIterator<FeatureData> si =
     786        HibernateUtil.loadIterator(FeatureData.class, query, dc.getSessionControl());
    786787      while (si.hasNext())
    787788      {
  • branches/2.4-stable/src/core/net/sf/basedb/core/RawDataBatcher.java

    r3747 r3808  
    192192      */
    193193      query.setInteger("arrayDesign", arrayDesign.getId());
    194       ScrollIterator<FeatureData> si = HibernateUtil.loadIterator(FeatureData.class, query);
     194      ScrollIterator<FeatureData> si =
     195        HibernateUtil.loadIterator(FeatureData.class, query, dc.getSessionControl());
    195196      while (si.hasNext())
    196197      {
  • branches/2.4-stable/src/core/net/sf/basedb/core/ReporterScoreQuery.java

    r2474 r3808  
    5858    enableFilters(dc);
    5959    long totalCount = -1;
     60    SessionControl sc = dc.getSessionControl();
    6061   
    6162    // Load the total count if it is requested
     
    6566    }
    6667
    67     ScrollIterator<ReporterListScoreData> result = HibernateUtil.loadIterator(ReporterListScoreData.class, getMainHqlQuery(dc));
     68    ScrollIterator<ReporterListScoreData> result =
     69      HibernateUtil.loadIterator(ReporterListScoreData.class, getMainHqlQuery(dc), sc);
    6870    disableFilters(dc);
    6971    return new ReporterScoreResultIterator(result, dc, totalCount);
  • branches/2.4-stable/src/core/net/sf/basedb/core/SessionControl.java

    r3679 r3808  
    112112 
    113113  /**
     114    If the session control has been closed it can no longer be used.
     115  */
     116  private boolean closed;
     117 
     118  /**
    114119    Stores name and value from {@link ClientDefaultSettingData}.
    115120  */
     
    192197    Get the time this object last was accessed. Used by the cleanup timer
    193198    in {@link Application#cleanSessionControlCache(boolean)}
    194   */
    195   long getLastAccess()
     199    @since 2.4.5
     200  */
     201  public long getLastAccess()
    196202  {
    197203    return lastAccess;
     
    204210  public void updateLastAccess()
    205211  {
     212    if (closed) throw new PermissionDeniedException("SessonControl is closed");
    206213    lastAccess = System.currentTimeMillis();
    207214  }
     215 
     216  /**
     217    If this session control has been closed or not. A closed session
     218    control can't be used.
     219    @return TRUE if the session control is closed
     220    @since 2.4.5
     221  */
     222  public boolean isClosed()
     223  {
     224    return closed;
     225  }
     226 
     227  /**
     228    Close this session control so it can't be used again.
     229    @since 2.4.5
     230  */
     231  public void close()
     232  {
     233    if (isLoggedIn()) logout();
     234    closed = true;
     235  }
     236 
    208237 
    209238  /**
     
    693722  public boolean isLoggedIn()
    694723  {
    695     updateLastAccess();
    696724    return loginInfo != null;
    697725  }
     
    14051433      query.setInteger("itemType", item.getValue());
    14061434      query.setString("subContext", subContext);
    1407       for (Object ctx : HibernateUtil.loadList(Object.class, query))
     1435      for (Object ctx : HibernateUtil.loadList(Object.class, query, null))
    14081436      {
    14091437        Object[] o = (Object[])ctx;
     
    16651693    */
    16661694    query.setInteger("client", clientId);
    1667     return listToMap(HibernateUtil.loadList(ClientDefaultSettingData.class, query));
     1695    return listToMap(HibernateUtil.loadList(ClientDefaultSettingData.class, query, null));
    16681696  }
    16691697
     
    16801708    */
    16811709    query.setInteger("user", userId);
    1682     return listToMap(HibernateUtil.loadList(UserDefaultSettingData.class, query));
     1710    return listToMap(HibernateUtil.loadList(UserDefaultSettingData.class, query, null));
    16831711  }
    16841712
     
    16961724    query.setInteger("user", userId);
    16971725    query.setInteger("client", clientId);
    1698     return listToMap(HibernateUtil.loadList(UserClientSettingData.class, query));
     1726    return listToMap(HibernateUtil.loadList(UserClientSettingData.class, query, null));
    16991727  }
    17001728 
     
    17161744  {
    17171745    // Load the existing settings from the database
    1718     List<I> dbSettings = HibernateUtil.loadList(dataClass, query);
     1746    List<I> dbSettings = HibernateUtil.loadList(dataClass, query, null);
    17191747    // Iterator the existing settings and check what has happened to them
    17201748    for (SettingData s : dbSettings)
     
    17861814  protected void cleanUp()
    17871815  {
    1788     if (isLoggedIn()) logout();
     1816    if (!isClosed() && isLoggedIn()) logout();
    17891817  }
    17901818 
     
    17991827      cleanUp();
    18001828    }
    1801     catch (BaseException ex)
    1802     {
    1803       log.warn("Exception during SessionControl.finalize()", ex);
     1829    catch (Throwable t)
     1830    {
     1831      log.warn("Exception during SessionControl.finalize()", t);
    18041832    }
    18051833    super.finalize();
    18061834  }
    1807 
     1835 
    18081836  /**
    18091837    Internal class to hold information about the logged in user.
  • branches/2.4-stable/src/core/net/sf/basedb/core/Trashcan.java

    r3675 r3808  
    7373    {
    7474      org.hibernate.Session session = dc.getHibernateSession();
     75      SessionControl sc = dc.getSessionControl();
    7576      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_REMOVED_ITEMS");
    7677      /*
     
    8283      filter.setParameter("owner", dc.getSessionControl().getLoggedInUserId());
    8384     
    84       List<RemovableData> removed = HibernateUtil.loadList(RemovableData.class, query);
     85      List<RemovableData> removed = HibernateUtil.loadList(RemovableData.class, query, sc);
    8586      List<Removable> items = new ArrayList<Removable>(removed.size());
    8687     
  • branches/2.4-stable/src/core/net/sf/basedb/core/Update.java

    r3679 r3808  
    895895      // Delete all affymetrix formulas
    896896      query = HibernateUtil.createQuery(session, "SELECT frm FROM FormulaData frm WHERE frm.rawDataType = 'affymetrix'");
    897       List<FormulaData> affyFormulas = HibernateUtil.loadList(FormulaData.class, query);
     897      List<FormulaData> affyFormulas = HibernateUtil.loadList(FormulaData.class, query, null);
    898898      for (FormulaData affyFormula : affyFormulas)
    899899      {
     
    11341134        FROM FileData f
    11351135      */
    1136       List<Integer> ids = HibernateUtil.loadList(Integer.class, query);
     1136      List<Integer> ids = HibernateUtil.loadList(Integer.class, query, null);
    11371137      if (ids.size() > 0)
    11381138      {
     
    11491149        FROM ExperimentData xp
    11501150      */
    1151       ids = HibernateUtil.loadList(Integer.class, query);
     1151      ids = HibernateUtil.loadList(Integer.class, query, null);
    11521152      if (ids.size() > 0)
    11531153      {
     
    11641164        FROM RawBioAssayData rba
    11651165      */
    1166       ids = HibernateUtil.loadList(Integer.class, query);
     1166      ids = HibernateUtil.loadList(Integer.class, query, null);
    11671167      if (ids.size() > 0)
    11681168      {
     
    12131213        WHERE dcd.id = :dataCube
    12141214      */
    1215       for (DataCubeData cubeData : HibernateUtil.loadList(DataCubeData.class, query))
     1215      for (DataCubeData cubeData : HibernateUtil.loadList(DataCubeData.class, query, null))
    12161216      {
    12171217        DataCube cube = dc.getItem(DataCube.class, cubeData);
     
    12741274          JOIN evt.sources src         
    12751275         */
    1276       List<Object[]> events = HibernateUtil.loadList(Object[].class, eventQuery);
    1277       events.addAll(HibernateUtil.loadList(Object[].class, sourcesQuery));
     1276      List<Object[]> events = HibernateUtil.loadList(Object[].class, eventQuery, null);
     1277      events.addAll(HibernateUtil.loadList(Object[].class, sourcesQuery, null));
    12781278     
    12791279      // Calculate the remaining quantity for each biomaterial
     
    13551355        WHERE f.lastUpdate IS NULL AND NOT f.internalName IS NULL
    13561356      */
    1357       List<FileData> files = HibernateUtil.loadList(FileData.class, query);
     1357      List<FileData> files = HibernateUtil.loadList(FileData.class, query, null);
    13581358      for (FileData fData : files)
    13591359      {
     
    13981398        "SELECT f FROM FileData f");
    13991399     
    1400       List<FileData> files = HibernateUtil.loadList(FileData.class, query);
     1400      List<FileData> files = HibernateUtil.loadList(FileData.class, query, null);
    14011401      for (FileData fData : files)
    14021402      {
     
    14501450        "SELECT t FROM TransformationData t");
    14511451     
    1452       List<TransformationData> transformations = HibernateUtil.loadList(TransformationData.class, query);
     1452      List<TransformationData> transformations = HibernateUtil.loadList(TransformationData.class, query, null);
    14531453      Map<JobData, Set<ExperimentData>> experiments = new HashMap<JobData, Set<ExperimentData>>();
    14541454      for (TransformationData transformation : transformations)
     
    15241524      query.setEntity("pluginDefinition", base1Executer);
    15251525      List<PluginConfigurationData> configurations =
    1526         HibernateUtil.loadList(PluginConfigurationData.class, query);
     1526        HibernateUtil.loadList(PluginConfigurationData.class, query, null);
    15271527
    15281528      // Delete AnyToAny for each configuration
     
    16761676            )
    16771677          */
    1678           List<PlateMappingData> mappings = HibernateUtil.loadList(PlateMappingData.class, pmQuery);
     1678          List<PlateMappingData> mappings = HibernateUtil.loadList(PlateMappingData.class, pmQuery, null);
    16791679          if (mappings != null && mappings.size() > 0)
    16801680          {
     
    16951695            {
    16961696              pQuery.setEntity("plateMapping", mapping);
    1697               List<PlateData> plates = HibernateUtil.loadList(PlateData.class, pQuery);
     1697              List<PlateData> plates = HibernateUtil.loadList(PlateData.class, pQuery, null);
    16981698              if (plates != null && plates.size() > 0)
    16991699              {
  • branches/2.4-stable/src/core/net/sf/basedb/core/User.java

    r3679 r3808  
    146146      */
    147147      query.setParameterList("groups", groupIds, org.hibernate.Hibernate.INTEGER);
    148       userIds.addAll(HibernateUtil.loadList(Integer.class, query));
     148      userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
    149149     
    150150      // Get the users that have a quota group among the same groups
     
    156156      */
    157157      query.setParameterList("groups", groupIds, org.hibernate.Hibernate.INTEGER);
    158       userIds.addAll(HibernateUtil.loadList(Integer.class, query));
     158      userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
    159159    }
    160160    return userIds;
     
    174174      WHERE grp.default = true
    175175    */
    176     List<GroupData> defaultGroups = HibernateUtil.loadList(GroupData.class, query);
     176    List<GroupData> defaultGroups = HibernateUtil.loadList(GroupData.class, query, null);
    177177    for (GroupData group : defaultGroups)
    178178    {
     
    185185      WHERE rle.default = true
    186186    */
    187     List<RoleData> defaultRoles = HibernateUtil.loadList(RoleData.class, query);
     187    List<RoleData> defaultRoles = HibernateUtil.loadList(RoleData.class, query, null);
    188188    for (RoleData role : defaultRoles)
    189189    {
     
    10901090    query.setEntity("user", this.getData());
    10911091
    1092     List<OwnableData> ownedBy = HibernateUtil.loadList(OwnableData.class, query);
     1092    List<OwnableData> ownedBy = HibernateUtil.loadList(OwnableData.class, query, sc);
    10931093    List<Ownable> items = new ArrayList<Ownable>(ownedBy.size());
    10941094
Note: See TracChangeset for help on using the changeset viewer.