Changeset 3949


Ignore:
Timestamp:
Nov 12, 2007, 2:23:51 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #820

File:
1 edited

Legend:

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

    r3808 r3949  
    378378    */
    379379    query.setEntity("pluginDefinition", this.getData());
    380     return HibernateUtil.loadData(Long.class, query) > 0 || super.isUsed();
     380    long count = HibernateUtil.loadData(Long.class, query);
     381    if (count == 0)
     382    {
     383      query = HibernateUtil.getPredefinedQuery(session,
     384        "GET_JOBS_FOR_PLUGINDEFINITION", "count(*)");
     385      /*
     386        SELECT {1}
     387        FROM JobData j
     388        WHERE j.pluginDefinition = :pluginDefinition
     389      */
     390      query.setEntity("pluginDefinition", this.getData());
     391      count = HibernateUtil.loadData(Long.class, query);
     392    }
     393    return count > 0 || super.isUsed();
    381394  }
    382395  /**
     
    384397    <ul>
    385398    <li>{@link PluginConfiguration}:s created from this plugin
     399    <li>{@link Job}:s using this plugin
    386400    <ul>
    387401    @since 2.2
     
    392406    Set<ItemProxy> using = super.getUsingItems();
    393407    org.hibernate.Session session = getDbControl().getHibernateSession();
     408
     409    // Plugin configurations
    394410    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    395411      "GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION", "pc.id");
     
    401417    query.setEntity("pluginDefinition", this.getData());
    402418    addUsingItems(using, Item.PLUGINCONFIGURATION, query);
     419
     420    // Jobs
     421    query = HibernateUtil.getPredefinedQuery(session,
     422      "GET_JOBS_FOR_PLUGINDEFINITION", "j.id");
     423      /*
     424        SELECT {1}
     425        FROM JobData j
     426        WHERE j.pluginDefinition = :pluginDefinition
     427      */
     428    query.setEntity("pluginDefinition", this.getData());
     429    addUsingItems(using, Item.JOB, query);
     430   
    403431    return using;
    404432  }
Note: See TracChangeset for help on using the changeset viewer.