Changeset 7377


Ignore:
Timestamp:
May 19, 2017, 1:54:38 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2084: Upgrade to Hibernate 5.2

Fixed all remaining queries without a return type parameter.

Location:
branches/hibernate-5.2/src/core/net/sf/basedb
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AbstractHqlQuery.java

    r7372 r7377  
    226226    @return A <code>org.hibernate.query.Query</code> object
    227227  */
    228   org.hibernate.query.Query<?> getMainHqlQuery(DbControl dc)
     228  @SuppressWarnings("unchecked")
     229  <R> org.hibernate.query.Query<R> getMainHqlQuery(DbControl dc, Class<R> returnType)
    229230  {
    230231    if (lastMainQuery == null || lastMainDc != dc)
     
    234235      if (stateless)
    235236      {
    236         lastMainQuery =  HibernateUtil.createQuery(dc.getStatelessSession(), mainHql);
     237        lastMainQuery =  HibernateUtil.createQuery(dc.getStatelessSession(), mainHql, returnType);
    237238      }
    238239      else
    239240      {
    240         lastMainQuery =  HibernateUtil.createQuery(dc.getHibernateSession(), mainHql);
     241        lastMainQuery =  HibernateUtil.createQuery(dc.getHibernateSession(), mainHql, returnType);
    241242      }
    242243    }
     
    246247    if (getFirstResult() >= 0) lastMainQuery.setFirstResult(getFirstResult());
    247248    if (getMaxResults() > 0) lastMainQuery.setMaxResults(getMaxResults());
    248     return lastMainQuery;
    249   }
    250  
    251   // TODO - is this the best solution??
    252   <T> org.hibernate.query.Query<T> getMainHqlQuery(DbControl dc, Class<T> returnType)
    253   {
    254     return (Query<T>)getMainHqlQuery(dc);
     249    return (org.hibernate.query.Query<R>)lastMainQuery;
    255250  }
    256251 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationBatcher.java

    r7374 r7377  
    124124  // Uses a list of ParameterValue.id as input parameter so we can load
    125125  // values for multiple annotations with a single query
    126   private final org.hibernate.query.Query[] loadAnnotationValues;
     126  private final org.hibernate.query.Query<Object[]>[] loadAnnotationValues;
    127127
    128128  // Batcher for inserting rows into the "ParameterValues" table
     
    215215    @since 3.11
    216216  */
    217   @SuppressWarnings({ "unchecked", "rawtypes" })
     217  @SuppressWarnings({ "unchecked" })
    218218  private AnnotationBatcher(DbControl dc, Item itemType, Integer projectId)
    219219  {
     
    273273        this.valueIds[t.ordinal()] = new ArrayList<Integer>();
    274274        this.loadAnnotationValues[t.ordinal()] = HibernateUtil.createSqlQuery(statelessSession,
    275           PredefinedQuery.getQueryString("AB_LOAD_ANNOTATION_VALUES", t.getTableName()));
     275          PredefinedQuery.getQueryString("AB_LOAD_ANNOTATION_VALUES", t.getTableName()), Object[].class);
    276276      }
    277277     
     
    629629        }
    630630       
    631         org.hibernate.query.Query query = loadAnnotationValues[typeIndex];
     631        org.hibernate.query.Query<Object[]> query = loadAnnotationValues[typeIndex];
    632632        query.setParameterList("listOfIds", valueIds[typeIndex], Type.INT.getTypeWrapper().getHibernateType());
    633633     
    634         list = HibernateUtil.loadList(Object[].class, query, null);
     634        list = HibernateUtil.loadList(query, null);
    635635        if (isDebugEnabled)
    636636        {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationBetweenRestriction.java

    r7372 r7377  
    164164 
    165165  @Override
    166   void setRestrictionParameters(NativeQuery query)
     166  void setRestrictionParameters(NativeQuery<?> query)
    167167  {
    168168    Type parameterType = valueType;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationInRestriction.java

    r7372 r7377  
    111111 
    112112  @Override
    113   void setRestrictionParameters(NativeQuery query)
     113  void setRestrictionParameters(NativeQuery<?> query)
    114114  {
    115115    query.setParameterList("values", values);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationRestriction.java

    r7374 r7377  
    115115    -------------------------------------------
    116116  */
     117  @SuppressWarnings("unchecked")
    117118  @Override
    118119  public String toQl(Query query, DbControl dc)
     
    333334      used to query the database
    334335  */
    335   abstract void setRestrictionParameters(NativeQuery query);
     336  abstract void setRestrictionParameters(NativeQuery<?> query);
    336337 
    337338  /**
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationSet.java

    r7374 r7377  
    214214    @since 3.2
    215215  */
    216   @SuppressWarnings("unchecked")
    217216  static synchronized int deleteEmptyAnnotationSets(org.hibernate.Session session, ProgressReporter progress)
    218217  {
     
    231230        " order by [aa].[item_type]";
    232231   
    233     org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, sql);
    234     List<Object[]> allEmpty = (List<Object[]>)query.list();
     232    org.hibernate.query.Query<Object[]> query = HibernateUtil.createSqlQuery(session, sql, Object[].class);
     233    List<Object[]> allEmpty = query.list();
    235234    if (progress != null)
    236235    {
     
    263262    // and nullify the reference from the item tables
    264263    String deleteSql = "delete from [AnnotationSets] where [id] in (:ids)";
    265     org.hibernate.query.Query deleteQuery = HibernateUtil.createSqlQuery(session, deleteSql);
     264    org.hibernate.query.Query<?> deleteQuery = HibernateUtil.createSqlQuery(session, deleteSql);
    266265
    267266    // Divide the query into chunks since the database driver may not support
     
    275274
    276275      String nullifySql = "update [" + table + "] set [annotationset_id] = null where [annotationset_id] in (:ids)";
    277       org.hibernate.query.Query nullifyQuery = HibernateUtil.createSqlQuery(session, nullifySql);
     276      org.hibernate.query.Query<?> nullifyQuery = HibernateUtil.createSqlQuery(session, nullifySql);
    278277
    279278      int startIndex = 0;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationSimpleRestriction.java

    r7372 r7377  
    265265 
    266266  @Override
    267   void setRestrictionParameters(NativeQuery query)
     267  void setRestrictionParameters(NativeQuery<?> query)
    268268  {
    269269    for (ParameterExpression pe : parameters)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationType.java

    r7376 r7377  
    153153  public static Set<Integer> getAllAnnotationTypesWithInheritanceDisabled(DbControl dc)
    154154  {
    155     org.hibernate.query.Query query = HibernateUtil.createQuery(dc.getHibernateSession(),
    156       "SELECT at.id FROM AnnotationTypeData at WHERE at.disableInheritance=true");
    157     return Collections.unmodifiableSet(new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, dc.getSessionControl())));
     155    org.hibernate.query.Query<Integer> query = HibernateUtil.createQuery(dc.getHibernateSession(),
     156      "SELECT at.id FROM AnnotationTypeData at WHERE at.disableInheritance=true", Integer.class);
     157    return Collections.unmodifiableSet(new HashSet<Integer>(HibernateUtil.loadList(query, dc.getSessionControl())));
    158158  }
    159159 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AuthenticationContext.java

    r7374 r7377  
    8585  public UserData getUserByExternalId(String id)
    8686  {
    87     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_EXTERNAL_ID");
     87    org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session,
     88      "GET_USER_FOR_EXTERNAL_ID", UserData.class);
    8889    /*
    8990      SELECT usr
     
    9293    */
    9394    query.setParameter("externalId", id);
    94     return HibernateUtil.loadData(UserData.class, query);
     95    return HibernateUtil.loadData(query);
    9596  }
    9697 
     
    114115      sql += " WHERE " + restriction;
    115116    }
    116     org.hibernate.query.Query query = HibernateUtil.createQuery(session, sql);
     117    org.hibernate.query.Query<UserData> query = HibernateUtil.createQuery(session, sql, UserData.class);
    117118    if (parameters != null)
    118119    {
     
    122123      }
    123124    }
    124     return HibernateUtil.loadList(UserData.class, query, getSessionControl());
     125    return HibernateUtil.loadList(query, getSessionControl());
    125126  }
    126127 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/BioAssaySet.java

    r7376 r7377  
    14161416   
    14171417    // 2a. Find all data cubes used by at least one of the bioassaysets
    1418     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBES_FOR_BIOASSAYSETS");
     1418    org.hibernate.query.Query<DataCubeData> cubeQuery = HibernateUtil.getPredefinedQuery(session,
     1419      "FIND_DATACUBES_FOR_BIOASSAYSETS", DataCubeData.class);
    14191420    /*
    14201421      SELECT DISTINCT cbe
     
    14231424      WHERE bas IN (:basList)
    14241425    */
    1425     query.setParameterList("basList", all);
    1426     List<DataCubeData> possibleCubes = HibernateUtil.loadList(DataCubeData.class, query, sc);
     1426    cubeQuery.setParameterList("basList", all);
     1427    List<DataCubeData> possibleCubes = HibernateUtil.loadList(cubeQuery, sc);
    14271428   
    14281429    // 2b. Among the found data cubes, find those that are also used by other bioassaysets
    14291430    if (possibleCubes.size() > 0)
    14301431    {
    1431       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBES_USED_BY_OTHERS");
     1432      cubeQuery = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBES_USED_BY_OTHERS", DataCubeData.class);
    14321433      /*
    14331434        SELECT cbe
     
    14371438        AND cbe IN (:possibleCubes)
    14381439      */
    1439       query.setParameterList("basList", all);
    1440       query.setParameterList("possibleCubes", possibleCubes);
    1441       possibleCubes.removeAll(HibernateUtil.loadList(DataCubeData.class, query, sc));
     1440      cubeQuery.setParameterList("basList", all);
     1441      cubeQuery.setParameterList("possibleCubes", possibleCubes);
     1442      possibleCubes.removeAll(HibernateUtil.loadList(cubeQuery, sc));
    14421443     
    14431444 
     
    14521453    // 3a. Find all layers that are used by at least one of the bioassaysets that are not
    14531454    //     part of the already deleted data cubes
     1455    org.hibernate.query.Query<DataCubeLayerData> layerQuery = null;
    14541456    if (possibleCubes.size() == 0)
    14551457    {
    1456       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBELAYERS_FOR_BIOASSAYSETS");
     1458      layerQuery = HibernateUtil.getPredefinedQuery(session,
     1459        "FIND_DATACUBELAYERS_FOR_BIOASSAYSETS", DataCubeLayerData.class);
    14571460      /*
    14581461        SELECT lay
     
    14611464        WHERE bas IN (:basList)
    14621465      */
    1463       query.setParameterList("basList", all);
     1466      layerQuery.setParameterList("basList", all);
    14641467    }
    14651468    else
    14661469    {
    1467       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES");
     1470      layerQuery = HibernateUtil.getPredefinedQuery(session,
     1471        "FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES", DataCubeLayerData.class);
    14681472      /*
    14691473        SELECT lay
     
    14731477        AND lay.dataCube NOT IN (:deletedCubes)
    14741478      */
    1475       query.setParameterList("basList", all);
    1476       query.setParameterList("deletedCubes", possibleCubes);
    1477     }
    1478     List<DataCubeLayerData> possibleLayers = HibernateUtil.loadList(DataCubeLayerData.class, query, sc);
     1479      layerQuery.setParameterList("basList", all);
     1480      layerQuery.setParameterList("deletedCubes", possibleCubes);
     1481    }
     1482    List<DataCubeLayerData> possibleLayers = HibernateUtil.loadList(layerQuery, sc);
    14791483   
    14801484    if (possibleLayers.size() > 0)
    14811485    {
    14821486      // 3b. Among the found layers, find thos the are also used by other bioassaysets
    1483       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBELAYERS_USED_BY_OTHERS");
     1487      layerQuery = HibernateUtil.getPredefinedQuery(session,
     1488        "FIND_DATACUBELAYERS_USED_BY_OTHERS", DataCubeLayerData.class);
    14841489      /*
    14851490        SELECT lay
     
    14891494        AND lay IN (:possibleLayers)
    14901495      */
    1491       query.setParameterList("basList", all);
    1492       query.setParameterList("possibleLayers", possibleLayers);
    1493       possibleLayers.removeAll(HibernateUtil.loadList(DataCubeLayerData.class, query, sc));
     1496      layerQuery.setParameterList("basList", all);
     1497      layerQuery.setParameterList("possibleLayers", possibleLayers);
     1498      possibleLayers.removeAll(HibernateUtil.loadList(layerQuery, sc));
    14941499     
    14951500      // 3c. Delete data from the remaining layers
     
    15031508    // 4a. Find all filters that are used by at least one of the bioassaysets that are not
    15041509    //     part of the already deleted data cubes
     1510    org.hibernate.query.Query<DataCubeFilterData> filterQuery = null;
    15051511    if (possibleCubes.size() == 0)
    15061512    {
    1507       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS");
     1513      filterQuery = HibernateUtil.getPredefinedQuery(session,
     1514        "FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS", DataCubeFilterData.class);
    15081515      /*
    15091516        SELECT flt
     
    15121519        WHERE bas IN (:basList)
    15131520      */
    1514       query.setParameterList("basList", all);
     1521      filterQuery.setParameterList("basList", all);
    15151522    }
    15161523    else
    15171524    {
    1518       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES");
     1525      filterQuery = HibernateUtil.getPredefinedQuery(session,
     1526        "FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES", DataCubeFilterData.class);
    15191527      /*
    15201528        SELECT flt
     
    15241532        AND flt.dataCube NOT IN (:deletedCubes)
    15251533      */
    1526       query.setParameterList("basList", all);
    1527       query.setParameterList("deletedCubes", possibleCubes);
    1528     }
    1529     List<DataCubeFilterData> possibleFilters = HibernateUtil.loadList(DataCubeFilterData.class, query, sc);
     1534      filterQuery.setParameterList("basList", all);
     1535      filterQuery.setParameterList("deletedCubes", possibleCubes);
     1536    }
     1537    List<DataCubeFilterData> possibleFilters = HibernateUtil.loadList(filterQuery, sc);
    15301538   
    15311539    if (possibleFilters.size() > 0)
    15321540    {
    15331541      // 4b. Among the found filters, find those the are also used by other bioassaysets
    1534       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEFILTERS_USED_BY_OTHERS");
     1542      filterQuery = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEFILTERS_USED_BY_OTHERS", DataCubeFilterData.class);
    15351543      /*
    15361544        SELECT flt
     
    15401548        AND flt IN (:possibleFilters)
    15411549      */
    1542       query.setParameterList("basList", all);
    1543       query.setParameterList("possibleFilters", possibleFilters);
    1544       possibleFilters.removeAll(HibernateUtil.loadList(DataCubeFilterData.class, query, sc));
     1550      filterQuery.setParameterList("basList", all);
     1551      filterQuery.setParameterList("possibleFilters", possibleFilters);
     1552      possibleFilters.removeAll(HibernateUtil.loadList(filterQuery, sc));
    15451553
    15461554      // 4c. Delete data from the remaining layers
     
    15541562    // 5a. Find all extra values that are used by at least one of the bioassaysets that are not
    15551563    //     part of the already deleted data cubes
     1564    org.hibernate.query.Query<DataCubeExtraValueData> extraQuery = null;
    15561565    if (possibleCubes.size() == 0)
    15571566    {
    1558       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS");
     1567      extraQuery = HibernateUtil.getPredefinedQuery(session,
     1568        "FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS", DataCubeExtraValueData.class);
    15591569      /*
    15601570        SELECT ev
     
    15631573        WHERE bas IN (:basList)
    15641574      */
    1565       query.setParameterList("basList", all);
     1575      extraQuery.setParameterList("basList", all);
    15661576    }
    15671577    else
    15681578    {
    1569       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES");
     1579      extraQuery = HibernateUtil.getPredefinedQuery(session,
     1580        "FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES", DataCubeExtraValueData.class);
    15701581      /*
    15711582        SELECT ev
     
    15751586        AND ev.dataCube NOT IN (:deletedCubes)
    15761587      */
    1577       query.setParameterList("basList", all);
    1578       query.setParameterList("deletedCubes", possibleCubes);
    1579     }
    1580     List<DataCubeExtraValueData> possibleExtraValues = HibernateUtil.loadList(DataCubeExtraValueData.class, query, sc);
     1588      extraQuery.setParameterList("basList", all);
     1589      extraQuery.setParameterList("deletedCubes", possibleCubes);
     1590    }
     1591    List<DataCubeExtraValueData> possibleExtraValues = HibernateUtil.loadList(extraQuery, sc);
    15811592   
    15821593    if (possibleExtraValues.size() > 0)
    15831594    {
    15841595      // 5b. Among the found extra values, find those the are also used by other bioassaysets
    1585       query = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS");
     1596      extraQuery = HibernateUtil.getPredefinedQuery(session, "FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS", DataCubeExtraValueData.class);
    15861597      /*
    15871598        SELECT ev
     
    15911602        AND ev IN (:possibleExtraValues)
    15921603      */
    1593       query.setParameterList("basList", all);
    1594       query.setParameterList("possibleExtraValues", possibleExtraValues);
    1595       possibleExtraValues.removeAll(HibernateUtil.loadList(DataCubeExtraValueData.class, query, sc));
     1604      extraQuery.setParameterList("basList", all);
     1605      extraQuery.setParameterList("possibleExtraValues", possibleExtraValues);
     1606      possibleExtraValues.removeAll(HibernateUtil.loadList(extraQuery, sc));
    15961607     
    15971608      // 5c. Delete data from the remaining extra values
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Group.java

    r7376 r7377  
    140140    {
    141141     
    142       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    143         "GET_CHILDGROUPS_IDS_FOR_GROUPS");
     142      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session,
     143        "GET_CHILDGROUPS_IDS_FOR_GROUPS", Integer.class);
    144144      /*
    145145        SELECT DISTINCT gg.childId
     
    151151      {
    152152        query.setParameterList("groups", allGroups, TypeWrapper.H_INTEGER);
    153       } while (allGroups.addAll(HibernateUtil.loadList(Integer.class, query, null)));
     153      } while (allGroups.addAll(HibernateUtil.loadList(query, null)));
    154154    }
    155155    return allGroups;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/HasAnnotationRestriction.java

    r7372 r7377  
    129129  }
    130130  @Override
    131   void setRestrictionParameters(NativeQuery query)
     131  void setRestrictionParameters(NativeQuery<?> query)
    132132  {}
    133133  @Override
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/HibernateUtil.java

    r7375 r7377  
    19361936    @since 3.12
    19371937  */
     1938  @SuppressWarnings("unchecked")
    19381939  static <R> NativeQuery<R> createSqlQuery(Session session, String sql, Class<R> returnType)
    19391940    throws BaseException
     
    19791980    @since 3.12
    19801981  */
     1982  @SuppressWarnings("unchecked")
    19811983  static <R> NativeQuery<R> createSqlQuery(StatelessSession session, String sql, Class<R> returnType)
    19821984    throws BaseException
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ItemKey.java

    r7376 r7377  
    185185      session = HibernateUtil.newSession();
    186186      tx = HibernateUtil.newTransaction(session);
    187       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "FIND_USED_ITEMKEY_IDS");
     187      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "FIND_USED_ITEMKEY_IDS", Integer.class);
    188188      /*
    189189        SELECT DISTINCT sd.itemKey.id
     
    191191        WHERE NOT sd.itemKey IS NULL
    192192      */
    193       Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     193      Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(query, null));
    194194      if (used.size() == 0) used.add(0);
    195       query = HibernateUtil.getPredefinedQuery(session, "SELECT_UNUSED_ITEMKEYS");
     195      org.hibernate.query.Query<ItemKeyData> keyQuery = HibernateUtil.getPredefinedQuery(session, "SELECT_UNUSED_ITEMKEYS", ItemKeyData.class);
    196196      /*
    197197        SELECT ik FROM ItemKeyData ik
    198198        WHERE ik.id NOT IN (:used)
    199199      */
    200       query.setParameterList("used", used, TypeWrapper.H_INTEGER);
    201       List<ItemKeyData> unused = HibernateUtil.loadList(ItemKeyData.class, query, null);
     200      keyQuery.setParameterList("used", used, TypeWrapper.H_INTEGER);
     201      List<ItemKeyData> unused = HibernateUtil.loadList(keyQuery, null);
    202202      for (ItemKeyData ik : unused)
    203203      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Migration.java

    r7372 r7377  
    946946      progress.append("..");
    947947      String sql = "SELECT max(id) FROM " + table.getFullQuotedTableName(engine);
    948       Query query = HibernateUtil.createSqlQuery(session, sql);
    949       maxId = HibernateUtil.loadData(Integer.class, query);
     948      Query<Integer> query = HibernateUtil.createSqlQuery(session, sql, Integer.class);
     949      maxId = HibernateUtil.loadData(query);
    950950    }
    951951    return maxId;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/PluginDefinition.java

    r7376 r7377  
    14381438      interfaceNames.add(in.getName());
    14391439    }
    1440     org.hibernate.query.Query query = HibernateUtil.createQuery(
    1441       getDbControl().getHibernateSession(), "SELECT pt FROM PluginTypeData pt");
    1442     List<PluginTypeData> types = HibernateUtil.loadList(PluginTypeData.class, query, null);
     1440    org.hibernate.query.Query<PluginTypeData> query = HibernateUtil.createQuery(
     1441      getDbControl().getHibernateSession(), "SELECT pt FROM PluginTypeData pt", PluginTypeData.class);
     1442    List<PluginTypeData> types = HibernateUtil.loadList(query, null);
    14431443
    14441444    for (PluginTypeData pt : types)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/PluginType.java

    r7372 r7377  
    126126  {
    127127    if (interfaceName != null) interfaceName = interfaceName.trim();
    128     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    129       dc.getHibernateSession(), "GET_PLUGINTYPE_FOR_INTERFACENAME");
     128    org.hibernate.query.Query<PluginTypeData> query = HibernateUtil.getPredefinedQuery(
     129      dc.getHibernateSession(), "GET_PLUGINTYPE_FOR_INTERFACENAME", PluginTypeData.class);
    130130    query.setParameter("interfaceName", interfaceName);
    131     PluginTypeData pt = HibernateUtil.loadData(PluginTypeData.class, query);
     131    PluginTypeData pt = HibernateUtil.loadData(query);
    132132    if (pt == null) throw new ItemNotFoundException("PluginType[interfaceName="+interfaceName+"]");
    133133    return dc.getItem(PluginType.class, pt);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Project.java

    r7374 r7377  
    688688        {
    689689          // Load all items
    690           inProject.addAll(HibernateUtil.loadList((org.hibernate.query.Query<ShareableData>)hql.getMainHqlQuery(dc), sc));
     690          inProject.addAll(HibernateUtil.loadList(hql.getMainHqlQuery(dc, ShareableData.class), sc));
    691691        }
    692692      }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ProjectKey.java

    r7376 r7377  
    137137      session = HibernateUtil.newSession();
    138138      tx = HibernateUtil.newTransaction(session);
    139       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "FIND_USED_PROJECTKEY_IDS");
     139      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session,
     140          "FIND_USED_PROJECTKEY_IDS", Integer.class);
    140141      /*
    141142        SELECT DISTINCT sd.projectKey.id
     
    143144        WHERE NOT sd.projectKey IS NULL
    144145      */
    145       Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     146      Set<Integer> used = new HashSet<Integer>(HibernateUtil.loadList(query, null));
    146147      if (used.size() == 0) used.add(0);
    147       query = HibernateUtil.getPredefinedQuery(session, "SELECT_UNUSED_PROJECTKEYS");
     148      org.hibernate.query.Query<ProjectKeyData> keyQuery = HibernateUtil.getPredefinedQuery(session,
     149          "SELECT_UNUSED_PROJECTKEYS", ProjectKeyData.class);
    148150      /*
    149151        SELECT pk FROM ProjectKeyData pk
    150152        WHERE pk.id NOT IN (:used)
    151153      */
    152       query.setParameterList("used", used, TypeWrapper.H_INTEGER);
    153       List<ProjectKeyData> unused = HibernateUtil.loadList(ProjectKeyData.class, query, null);
     154      keyQuery.setParameterList("used", used, TypeWrapper.H_INTEGER);
     155      List<ProjectKeyData> unused = HibernateUtil.loadList(keyQuery, null);
    154156      for (ProjectKeyData pk : unused)
    155157      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ProjectSpecificAnnotationsManager.java

    r7374 r7377  
    176176    {
    177177      if (deletedPrimary.size() == 0) deletedPrimary.add(-1);
    178       org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(session,
     178      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedSQLQuery(session,
    179179        "PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS");
    180180      /*
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ServiceSessionControl.java

    r7372 r7377  
    220220          log.debug("Creating schema " + actualCatalog + "/" + actualSchema + ": " + sql);
    221221        }
    222         Query q = session.createSQLQuery(sql);
     222        Query<?> q = session.createNativeQuery(sql);
    223223        q.executeUpdate();
    224224      }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/SessionControl.java

    r7376 r7377  
    22582258      {
    22592259        ClientData clientData = HibernateUtil.loadData(session, ClientData.class, clientId);
    2260         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_USER_CLIENT_SETTINGS");
     2260        org.hibernate.query.Query<UserClientSettingData> query =
     2261          HibernateUtil.getPredefinedQuery(session, "LOAD_USER_CLIENT_SETTINGS", UserClientSettingData.class);
    22612262        query.setParameter("user", userData.getId(), TypeWrapper.H_INTEGER);
    22622263        query.setParameter("client", clientData.getId(), TypeWrapper.H_INTEGER);
     
    22642265        saveAllCurrentContexts(session, userData, clientData);
    22652266      }
    2266       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_USER_DEFAULT_SETTINGS");
     2267      org.hibernate.query.Query<UserDefaultSettingData> query = HibernateUtil.getPredefinedQuery(session,
     2268        "LOAD_USER_DEFAULT_SETTINGS", UserDefaultSettingData.class);
    22672269      query.setParameter("user", userData.getId(), TypeWrapper.H_INTEGER);
    22682270      saveSettings(session, query, loginInfo.userDefaultSettings, UserDefaultSettingData.class, userData, null);
     
    22842286  */
    22852287  private <I extends SettingData>
    2286   void saveSettings(org.hibernate.Session session, org.hibernate.query.Query query, Map<String, SettingInfo> settings, Class<I> dataClass, UserData userData, ClientData clientData)
     2288  void saveSettings(org.hibernate.Session session, org.hibernate.query.Query<I> query, Map<String, SettingInfo> settings, Class<I> dataClass, UserData userData, ClientData clientData)
    22872289    throws BaseException
    22882290  {
    22892291    // Load the existing settings from the database
    2290     List<I> dbSettings = HibernateUtil.loadList(dataClass, query, null);
     2292    List<I> dbSettings = HibernateUtil.loadList(query, null);
    22912293    // Iterator the existing settings and check what has happened to them
    22922294    for (SettingData s : dbSettings)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Trashcan.java

    r7374 r7377  
    130130          hql.restrict(isRemoved);
    131131          if (restriction != null) hql.restrict(restriction);
    132           removed.addAll(HibernateUtil.loadList((org.hibernate.query.Query<RemovableData>)hql.getMainHqlQuery(dc), sc));
     132          removed.addAll(HibernateUtil.loadList(hql.getMainHqlQuery(dc, RemovableData.class), sc));
    133133        }
    134134      }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Unit.java

    r7376 r7377  
    2929
    3030import net.sf.basedb.core.Transactional.Action;
    31 import net.sf.basedb.core.data.AnnotationSetData;
    3231import net.sf.basedb.core.data.QuantityData;
    3332import net.sf.basedb.core.data.UnitData;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Update.java

    r7376 r7377  
    636636      if (schemaVersion > 0)
    637637      {
    638         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
    639           "SELECT usr.id, usr.login FROM UserData usr WHERE usr.systemId='" + User.ROOT + "'");
    640         Object[] user = (Object[])query.uniqueResult();
     638        org.hibernate.query.Query<Object[]> userQuery = HibernateUtil.createQuery(session,
     639          "SELECT usr.id, usr.login FROM UserData usr WHERE usr.systemId='" + User.ROOT + "'", Object[].class);
     640        Object[] user = userQuery.uniqueResult();
    641641        if (user == null)
    642642        {
     
    653653        {
    654654          // BASE 3
    655           query = HibernateUtil.createQuery(session,
    656             "SELECT cryptedPassword FROM PasswordData pwd WHERE pwd.id="+id);
    657           String cryptedPassword = HibernateUtil.loadData(String.class, query);
     655          org.hibernate.query.Query<String> pwdQuery = HibernateUtil.createQuery(session,
     656            "SELECT cryptedPassword FROM PasswordData pwd WHERE pwd.id="+id, String.class);
     657          String cryptedPassword = pwdQuery.uniqueResult();
    658658          if (!User.checkPassword(password, cryptedPassword))
    659659          {
     
    664664        {
    665665          // BASE 2.17
    666           query = HibernateUtil.createSqlQuery(session,
    667             "SELECT [md5password] FROM [Passwords] WHERE [id]="+id);
    668           String md5Password = HibernateUtil.loadData(String.class, query);
     666          org.hibernate.query.Query<String> pwdQuery = HibernateUtil.createSqlQuery(session,
     667            "SELECT [md5password] FROM [Passwords] WHERE [id]="+id, String.class);
     668          String md5Password = pwdQuery.uniqueResult();
    669669          if (!MD5.getHashString(password).equals(md5Password))
    670670          {
     
    812812      {
    813813        // Set destroyed=false on all bioplates
    814         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "SET_DISABLE_LOG_FOR_ANNOTATION_TYPES");
     814        org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session, "SET_DISABLE_LOG_FOR_ANNOTATION_TYPES");
    815815        /*
    816816          UPDATE AnnotationTypeData at
     
    897897      {
    898898        // Set projectAnnotations=false on all annotation types
    899         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
     899        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
    900900          "UPDATE AnnotationTypeData at " +
    901901          "SET at.projectAnnotations = false " +
     
    908908          "SET a.projectId = 0, a.overrideId = 0 " +
    909909          "WHERE a.projectId IS NULL OR a.overrideId IS NULL");
    910           query.executeUpdate();
     910        query.executeUpdate();
    911911      }
    912912     
     
    914914      {
    915915        // Set fingerprintType=MD5 on all file servers with a fingerprint
    916         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
     916        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
    917917          "UPDATE FileServerData fs " +
    918918          "SET fs.fingerprintType = 'MD5' " +
     
    960960      tx = HibernateUtil.newTransaction(session);
    961961
    962       org.hibernate.query.Query query = HibernateUtil.createQuery(session,
    963         "SELECT fsm FROM FileSetMemberData fsm");
    964       List<FileSetMemberData> members = HibernateUtil.loadList(FileSetMemberData.class, query, null);
     962      org.hibernate.query.Query<FileSetMemberData> query = HibernateUtil.createQuery(session,
     963        "SELECT fsm FROM FileSetMemberData fsm", FileSetMemberData.class);
     964      List<FileSetMemberData> members = HibernateUtil.loadList(query, null);
    965965      Set<String> allMembers = new HashSet<String>();
    966966      for (FileSetMemberData member : members)
     
    10501050          // Copy parent physical and derived bioassay information to the
    10511051          // new tables: ParentPhysicalBioAssays and ParentDerivedBioAssays
    1052           org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(session, "COPY_PARENT_PHYSICAL_BIOASSAYS");
     1052          org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedSQLQuery(session, "COPY_PARENT_PHYSICAL_BIOASSAYS");
    10531053          /*
    10541054            INSERT INTO ParentPhysicalBioAssays (physicalbioassay_id, derivedbioassay_id)
     
    11711171          " where bm.parent is null or bm.parentType is null";
    11721172     
    1173       org.hibernate.query.Query query = HibernateUtil.createQuery(session, hql);
    1174       List<BioMaterialEventData> events = HibernateUtil.loadList(BioMaterialEventData.class, query, null);
     1173      org.hibernate.query.Query<BioMaterialEventData> query = HibernateUtil.createQuery(session, hql, BioMaterialEventData.class);
     1174      List<BioMaterialEventData> events = HibernateUtil.loadList(query, null);
    11751175      int i = 0;
    11761176      for (BioMaterialEventData event : events)
     
    14191419        " where 0 in elements(lst.members)";
    14201420     
    1421       org.hibernate.query.Query query = HibernateUtil.createQuery(session, hql);
    1422       List<ItemListData> lists = HibernateUtil.loadList(ItemListData.class, query, null);
     1421      org.hibernate.query.Query<ItemListData> query = HibernateUtil.createQuery(session, hql, ItemListData.class);
     1422      List<ItemListData> lists = HibernateUtil.loadList(query, null);
    14231423      for (ItemListData list : lists)
    14241424      {
     
    14611461        " inner join [RawBioAssays] [rba] on [rba].[id] = [er].[rawbioassay_id]";
    14621462     
    1463       org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, sql);
    1464       List<Object[]> list = HibernateUtil.loadList(Object[].class, query, null);
     1463      org.hibernate.query.Query<Object[]> query = HibernateUtil.createSqlQuery(session, sql, Object[].class);
     1464      List<Object[]> list = HibernateUtil.loadList(query, null);
    14651465      for (Object[] entry : list)
    14661466      {
     
    15221522        "   where [i].[annotationset_id]=[ia].[annotationset_id] and [i].[annotation_id]=[a].[id])";
    15231523     
    1524       org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, sql);
     1524      org.hibernate.query.Query<?> query = HibernateUtil.createSqlQuery(session, sql);
    15251525      HibernateUtil.executeUpdate(query);
    15261526   
     
    15691569        " inner join [Annotations] [a] on [a].[id] = [i].[annotation_id]";
    15701570     
    1571       org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, sql);
    1572       List<Object[]> list = HibernateUtil.loadList(Object[].class, query, null);
     1571      org.hibernate.query.Query<Object[]> query = HibernateUtil.createSqlQuery(session, sql, Object[].class);
     1572      List<Object[]> list = HibernateUtil.loadList(query, null);
    15731573     
    15741574      for (Object[] entry : list)
     
    16401640        " and [xf].[annotationtype_id]=[a].[annotationtype_id]";
    16411641     
    1642       org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, sql);
    1643       List<Object[]> list = new ArrayList<Object[]>(HibernateUtil.loadList(Object[].class, query, null));
     1642      org.hibernate.query.Query<Object[]> query = HibernateUtil.createSqlQuery(session, sql, Object[].class);
     1643      List<Object[]> list = new ArrayList<Object[]>(HibernateUtil.loadList(query, null));
    16441644     
    16451645      for (Object[] entry : list)
     
    18431843      // Queries for deleting from Annotations+ParameterValues
    18441844      // that doesn't have any corresponding entry in one of the data values tables
    1845       org.hibernate.query.Query deleteAnnotations = HibernateUtil.createSqlQuery(session,
     1845      org.hibernate.query.Query<?> deleteAnnotations = HibernateUtil.createSqlQuery(session,
    18461846        "delete from [Annotations] [a] where [a].[value_id] in (:ids)");
    1847       org.hibernate.query.Query deleteInherited = HibernateUtil.createSqlQuery(session,
     1847      org.hibernate.query.Query<?> deleteInherited = HibernateUtil.createSqlQuery(session,
    18481848        "delete from [Annotations] [a] where [a].[inherited_id] in ("+
    18491849        "select [b].[id] from [Annotations] [b] where [b].[value_id] in (:ids))");
    1850       org.hibernate.query.Query deleteValues = HibernateUtil.createSqlQuery(session,
     1850      org.hibernate.query.Query<?> deleteValues = HibernateUtil.createSqlQuery(session,
    18511851        "delete from [ParameterValues] [p] where [p].[id] in (:ids)");
    18521852     
     
    18561856        // Note that Annotations.value_id is null for inherited annotations
    18571857        // so we must LEFT JOIN the data value table
    1858         org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session,
     1858        org.hibernate.query.Query<Integer> query = HibernateUtil.createSqlQuery(session,
    18591859          "select [a].[value_id] from [Annotations] [a] " +
    18601860          "inner join [AnnotationTypes] [at] on [at].[id]=[a].[annotationtype_id] "+
    18611861          "left join [" + t.getTableName() + "] [v] on [v].[id]=[a].[value_id] "+
    18621862          "where [at].[value_type] = "+t.getValue()+
    1863           " and [v].[id] is null and not [a].[value_id] is null");
     1863          " and [v].[id] is null and not [a].[value_id] is null", Integer.class);
    18641864       
    1865         List<Integer> valueIds = HibernateUtil.loadList(Integer.class, query, null);
     1865        List<Integer> valueIds = HibernateUtil.loadList(query, null);
    18661866        //System.out.println("Deleting["+t.name()+"]: " + valueIds);
    18671867        if (valueIds.size() > 0)
     
    19801980     
    19811981      // Load used quantity for all events
    1982       org.hibernate.query.Query eventQuery = HibernateUtil.createQuery(session,
    1983         "SELECT evt.bioMaterial.id, evt.usedQuantity FROM BioMaterialEventData evt WHERE NOT evt.usedQuantity IS NULL");
     1982      org.hibernate.query.Query<Object[]> eventQuery = HibernateUtil.createQuery(session,
     1983        "SELECT evt.bioMaterial.id, evt.usedQuantity FROM BioMaterialEventData evt WHERE NOT evt.usedQuantity IS NULL", Object[].class);
    19841984     
    19851985      // Load used quantity for sources to all events
    1986       org.hibernate.query.Query sourcesQuery = HibernateUtil.createQuery(session,
    1987         "SELECT src.bioMaterial.id, src.usedQuantity FROM BioMaterialEventSourceData src WHERE NOT src.usedQuantity IS NULL");
     1986      org.hibernate.query.Query<Object[]> sourcesQuery = HibernateUtil.createQuery(session,
     1987        "SELECT src.bioMaterial.id, src.usedQuantity FROM BioMaterialEventSourceData src WHERE NOT src.usedQuantity IS NULL", Object[].class);
    19881988 
    19891989      progress.display(10, "Loading biomaterial items...\n");
    19901990     
    1991       List<Object[]> events = HibernateUtil.loadList(Object[].class, eventQuery, null);
    1992       events.addAll(HibernateUtil.loadList(Object[].class, sourcesQuery, null));
     1991      List<Object[]> events = HibernateUtil.loadList(eventQuery, null);
     1992      events.addAll(HibernateUtil.loadList(sourcesQuery, null));
    19931993 
    19941994      // Calculate the remaining quantity for each biomaterial
     
    20622062  {
    20632063    org.hibernate.Transaction tx = null;
    2064     org.hibernate.query.Query query = null;
     2064    org.hibernate.query.Query<?> query = null;
    20652065    try
    20662066    {
     
    21022102  {
    21032103    org.hibernate.Transaction tx = null;
    2104     org.hibernate.query.Query query = null;
     2104    org.hibernate.query.Query<?> query = null;
    21052105    try
    21062106    {
     
    21622162  {
    21632163    org.hibernate.Transaction tx = null;
    2164     org.hibernate.query.Query query = null;
     2164    org.hibernate.query.Query<?> query = null;
    21652165    try
    21662166    {
     
    21832183  {
    21842184    org.hibernate.Transaction tx = null;
    2185     org.hibernate.query.Query query = null;
     2185    org.hibernate.query.Query<?> query = null;
    21862186    try
    21872187    {
     
    22052205  {
    22062206    org.hibernate.Transaction tx = null;
    2207     org.hibernate.query.Query query = null;
     2207    org.hibernate.query.Query<?> query = null;
    22082208    try
    22092209    {
     
    22762276  {
    22772277    org.hibernate.Transaction tx = null;
    2278     org.hibernate.query.Query query = null;
    22792278    try
    22802279    {
     
    22822281      tx = session.getTransaction().getStatus() == TransactionStatus.ACTIVE ? null : HibernateUtil.newTransaction(session);
    22832282     
    2284       query = HibernateUtil.createQuery(session, "select ctx from ContextData ctx where ctx.itemType = " + itemType.getValue());
    2285       List<ContextData> contexts = HibernateUtil.loadList(ContextData.class, query, null);
     2283      org.hibernate.query.Query<ContextData> query = HibernateUtil.createQuery(session,
     2284        "select ctx from ContextData ctx where ctx.itemType = " + itemType.getValue(), ContextData.class);
     2285      List<ContextData> contexts = HibernateUtil.loadList(query, null);
    22862286     
    22872287      for (ContextData ctx : contexts)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/User.java

    r7376 r7377  
    146146    {
    147147      // Get the users which are members of the same groups
    148       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_GROUPS");
     148      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_GROUPS", Integer.class);
    149149      /*
    150150        SELECT ug.userId
     
    153153      */
    154154      query.setParameterList("groups", groupIds, TypeWrapper.H_INTEGER);
    155       userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
     155      userIds.addAll(HibernateUtil.loadList(query, null));
    156156     
    157157      // Get the users that have a quota group among the same groups
    158       query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_QUOTAGROUPS");
     158      query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_QUOTAGROUPS", Integer.class);
    159159      /*
    160160        SELECT usr.id
     
    163163      */
    164164      query.setParameterList("groups", groupIds, TypeWrapper.H_INTEGER);
    165       userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
     165      userIds.addAll(HibernateUtil.loadList(query, null));
    166166    }
    167167    return userIds;
     
    175175  static void addDefultRolesAndGroups(org.hibernate.Session session, UserData user)
    176176  {
    177     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_DEFAULT_GROUPS");
     177    org.hibernate.query.Query<GroupData> grpQuery = HibernateUtil.getPredefinedQuery(session, "LOAD_DEFAULT_GROUPS", GroupData.class);
    178178    /*
    179179      SELECT grp
     
    181181      WHERE grp.default = true
    182182    */
    183     List<GroupData> defaultGroups = HibernateUtil.loadList(GroupData.class, query, null);
     183    List<GroupData> defaultGroups = HibernateUtil.loadList(grpQuery, null);
    184184    for (GroupData group : defaultGroups)
    185185    {
    186186      group.getUsers().add(user);
    187187    }
    188     query = HibernateUtil.getPredefinedQuery(session, "LOAD_DEFAULT_ROLES");
     188   
     189    org.hibernate.query.Query<RoleData> roleQuery = HibernateUtil.getPredefinedQuery(session, "LOAD_DEFAULT_ROLES", RoleData.class);
    189190    /*
    190191      SELECT rle
     
    192193      WHERE rle.default = true
    193194    */
    194     List<RoleData> defaultRoles = HibernateUtil.loadList(RoleData.class, query, null);
     195    List<RoleData> defaultRoles = HibernateUtil.loadList(roleQuery, null);
    195196    for (RoleData role : defaultRoles)
    196197    {
     
    245246    if (externalId != null) externalId = externalId.trim();
    246247    org.hibernate.Session session = dc.getHibernateSession();
    247     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_EXTERNAL_ID");
     248    org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_EXTERNAL_ID", UserData.class);
    248249    /*
    249250      SELECT usr
     
    251252      WHERE usr.externalId = :externalId
    252253    */
    253     query.setParameter("externalId", externalId);
    254     UserData userData = HibernateUtil.loadData(UserData.class, query);
     254    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     255    UserData userData = HibernateUtil.loadData(query);
    255256    return userData != null;
    256257  }
     
    12831284        {
    12841285          // Load all items
    1285           ownedBy.addAll(HibernateUtil.loadList((org.hibernate.query.Query<OwnableData>)hql.getMainHqlQuery(dc), sc));
     1286          ownedBy.addAll(HibernateUtil.loadList(hql.getMainHqlQuery(dc, OwnableData.class), sc));
    12861287        }
    12871288      }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/TransactionDetails.java

    r7372 r7377  
    145145    if (userName == null && userId != 0)
    146146    {
    147       Query query = logControl.createHqlQuery("select usr.name from UserData usr where usr.id = " + userId);
    148       userName = (String)query.uniqueResult();
     147      Query<String> query = logControl.createHqlQuery("select usr.name from UserData usr where usr.id = " + userId, String.class);
     148      userName = query.uniqueResult();
    149149    }
    150150    return userName;
     
    162162    if (projectName == null && projectId != 0)
    163163    {
    164       Query query = logControl.createHqlQuery("select prj.name from ProjectData prj where prj.id = " + projectId);
    165       projectName = (String)query.uniqueResult();
     164      Query<String> query = logControl.createHqlQuery("select prj.name from ProjectData prj where prj.id = " + projectId, String.class);
     165      projectName = query.uniqueResult();
    166166    }
    167167    return projectName;
     
    179179    if (pluginName == null && pluginId != 0)
    180180    {
    181       Query query = logControl.createHqlQuery("select plg.name from PluginDefinitionData plg where plg.id = " + pluginId);
    182       pluginName = (String)query.uniqueResult();
     181      Query<String> query = logControl.createHqlQuery("select plg.name from PluginDefinitionData plg where plg.id = " + pluginId, String.class);
     182      pluginName = query.uniqueResult();
    183183    }
    184184    return pluginName;
     
    196196    if (jobName == null && jobId != 0)
    197197    {
    198       Query query = logControl.createHqlQuery("select job.name from JobData job where job.id = " + jobId);
    199       jobName = (String)query.uniqueResult();
     198      Query<String> query = logControl.createHqlQuery("select job.name from JobData job where job.id = " + jobId, String.class);
     199      jobName = query.uniqueResult();
    200200    }
    201201    return jobName;
  • branches/hibernate-5.2/src/core/net/sf/basedb/util/units/UnitCache.java

    r4555 r7377  
    143143      if (autoReload && unit.isDetached())
    144144      {
    145         if (dc == null || !dc.isConnected())
     145        if (dc == null || dc.isClosed())
    146146        {
    147147          throw new ConnectionClosedException();
     
    188188  private Unit lookupUnitInDb(CacheKey key, boolean addToCache)
    189189  {
    190     if (dc == null || !dc.isConnected()) throw new ConnectionClosedException();
     190    if (dc == null || dc.isClosed()) throw new ConnectionClosedException();
    191191    if (query == null)
    192192    {
Note: See TracChangeset for help on using the changeset viewer.