Changeset 7374


Ignore:
Timestamp:
May 18, 2017, 2:17:13 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2084: Upgrade to Hibernate 5.2

Replaced calls to Query.setInteger() and other type-specific methods to Query.setParameter() and specified return-type parameter for many queries. Number of warnings down to 556.

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

Legend:

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

    r7372 r7374  
    2727import net.sf.basedb.core.data.AnnotationTypeData;
    2828import net.sf.basedb.core.data.UnitData;
     29import net.sf.basedb.core.hibernate.TypeWrapper;
    2930import net.sf.basedb.core.query.EntityQuery;
    3031import net.sf.basedb.util.EqualsHelper;
     
    285286        // Cloned annotations should remain
    286287        org.hibernate.Session session = getDbControl().getHibernateSession();
    287         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
     288        org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session,
    288289          "NULLIFY_LINK_FROM_CLONES");
    289290        /*
     
    293294          AND ad.source = CLONED
    294295        */
    295         query.setInteger("targetId", getId());
     296        query.setParameter("targetId", getId(), TypeWrapper.H_INTEGER);
    296297        HibernateUtil.executeUpdate(query);
    297298      }
     
    957958        if (annotationTypeIds == null)
    958959        {
    959           org.hibernate.query.Query atQuery = HibernateUtil.getPredefinedSQLQuery(dc.getHibernateSession(),
    960             "GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER");
     960          org.hibernate.query.Query<Integer> atQuery = HibernateUtil.getPredefinedSQLQuery(dc.getHibernateSession(),
     961            "GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER", Integer.class);
    961962         
    962963          // Owner
    963           atQuery.setInteger("owner", sc.getLoggedInUserId());
     964          atQuery.setParameter("owner", sc.getLoggedInUserId(), TypeWrapper.H_INTEGER);
    964965         
    965966          // All items keys for the logged in user
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationBatcher.java

    r7372 r7374  
    3939import net.sf.basedb.core.data.AnnotatableData;
    4040import net.sf.basedb.core.data.LoggableData;
     41import net.sf.basedb.core.hibernate.TypeWrapper;
    4142import net.sf.basedb.core.log.ChangeType;
    4243import net.sf.basedb.core.log.LoggingInterceptor;
     
    117118  // SQL query through Hibernate to load information about current annotations
    118119  // for a single item. Uses 'annotationSetId' as the only input parameter.
    119   private final org.hibernate.query.Query loadAnnotationInfo;
     120  private final org.hibernate.query.Query<Object[]> loadAnnotationInfo;
    120121 
    121122  // SQL query through Hibernate to load annotation values
     
    263264      // Initialize statements for loading information about current annotations
    264265      this.loadAnnotationInfo = HibernateUtil.createSqlQuery(statelessSession,
    265         PredefinedQuery.getQueryString("AB_LOAD_ANNOTATION_INFO"));
    266       loadAnnotationInfo.setInteger("activeProject", activeProjectId);
    267       loadAnnotationInfo.setInteger("defaultProject", projectId == null ? 0 : projectId);
     266        PredefinedQuery.getQueryString("AB_LOAD_ANNOTATION_INFO"), Object[].class);
     267      loadAnnotationInfo.setParameter("activeProject", activeProjectId, TypeWrapper.H_INTEGER);
     268      loadAnnotationInfo.setParameter("defaultProject", projectId == null ? 0 : projectId, TypeWrapper.H_INTEGER);
    268269      this.loadAnnotationValues = new org.hibernate.query.Query[types.length];
    269270      this.valueIds = new List[types.length];
     
    562563    {
    563564      currentAnnotationSetId = ((AnnotatableData)((BasicItem)item).getData()).getAnnotationSet().getId();
    564       loadAnnotationInfo.setInteger("annotationSet", currentAnnotationSetId);
     565      loadAnnotationInfo.setParameter("annotationSet", currentAnnotationSetId, TypeWrapper.H_INTEGER);
    565566      deleteSnapshotIfModifed = true;
    566567     
     
    572573      // Maps value_id -> Annotation info
    573574      Map<Integer, CurrentAnnotationInfo> tmp = new HashMap<Integer, CurrentAnnotationInfo>();
    574       List<Object[]> list = HibernateUtil.loadList(Object[].class, loadAnnotationInfo, null);
     575      List<Object[]> list = HibernateUtil.loadList(loadAnnotationInfo, null);
    575576
    576577      if (isDebugEnabled)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationRestriction.java

    r7372 r7374  
    191191
    192192    org.hibernate.Session session = dc.getHibernateSession();
    193     NativeQuery sqlQuery = HibernateUtil.createSqlQuery(session, sql);
    194     sqlQuery.addScalar("annotationset_id", TypeWrapper.INTEGER.getHibernateType());
     193    NativeQuery<?> sqlQuery = HibernateUtil.createSqlQuery(session, sql);
     194    sqlQuery.addScalar("annotationset_id", TypeWrapper.H_INTEGER);
    195195    if (options.includeInherited)
    196196    {
    197       sqlQuery.addScalar("id", TypeWrapper.INTEGER.getHibernateType());
    198       sqlQuery.addScalar("source", TypeWrapper.INTEGER.getHibernateType());
    199     }
    200     sqlQuery.setInteger("annotationType", annotationTypeId);
     197      sqlQuery.addScalar("id", TypeWrapper.H_INTEGER);
     198      sqlQuery.addScalar("source", TypeWrapper.H_INTEGER);
     199    }
     200    sqlQuery.setParameter("annotationType", annotationTypeId, TypeWrapper.H_INTEGER);
    201201    setRestrictionParameters(sqlQuery);
    202202   
     
    205205    {
    206206      if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    207       List<Object[]> twoIds = HibernateUtil.loadList(Object[].class, sqlQuery, sc);
     207      List<Object[]> twoIds = HibernateUtil.loadList((NativeQuery<Object[]>)sqlQuery, sc);
    208208      StringBuilder primarySets = new StringBuilder("0");
    209209      StringBuilder primaryAnnotations = new StringBuilder("0");
     
    233233        sql = sql.replace('[', oq).replace(']', cq);
    234234       
    235         sqlQuery = HibernateUtil.createSqlQuery(session, sql);
    236         sqlQuery.addScalar("sid", TypeWrapper.INTEGER.getHibernateType());
     235        NativeQuery<Integer> sqlQuery2 = HibernateUtil.createSqlQuery(session, sql, Integer.class);
     236        sqlQuery2.addScalar("sid", TypeWrapper.H_INTEGER);
    237237        if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    238         List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc);
     238        List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery2, sc);
    239239        for (Integer id : ids)
    240240        {
     
    247247    {
    248248      if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql);
    249       List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc);
     249      List<Integer> ids = HibernateUtil.loadList((NativeQuery<Integer>)sqlQuery, sc);
    250250      for (Integer id : ids)
    251251      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationSet.java

    r7373 r7374  
    140140      " WHERE item.annotationSet = :annotationSet";
    141141    org.hibernate.query.Query<Integer> query = HibernateUtil.createQuery(session, hql, Integer.class);
    142     query.setInteger("annotationSet", annotationSetId);
     142    query.setParameter("annotationSet", annotationSetId, TypeWrapper.H_INTEGER);
    143143    return HibernateUtil.loadData(query);
    144144  }
     
    290290        }
    291291       
    292         deleteQuery.setParameterList("ids", sublist, TypeWrapper.INTEGER.getHibernateType());
    293         nullifyQuery.setParameterList("ids", sublist, TypeWrapper.INTEGER.getHibernateType());
     292        deleteQuery.setParameterList("ids", sublist, TypeWrapper.H_INTEGER);
     293        nullifyQuery.setParameterList("ids", sublist, TypeWrapper.H_INTEGER);
    294294        nullifyQuery.executeUpdate();
    295295        deleteQuery.executeUpdate();
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnnotationType.java

    r7373 r7374  
    2424package net.sf.basedb.core;
    2525
    26 import net.sf.basedb.core.data.AnnotationSetData;
    2726import net.sf.basedb.core.data.ParameterValueData;
    2827import net.sf.basedb.core.data.AnnotationTypeData;
    2928import net.sf.basedb.core.data.QuantityData;
    3029import net.sf.basedb.core.data.UnitData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3131import net.sf.basedb.core.query.Restrictions;
    3232import net.sf.basedb.core.query.Expressions;
     
    401401            double offset = (oldUnit.getReferenceOffset() - defaultUnit.getReferenceOffset()) / defaultUnit.getReferenceFactor();
    402402            String tableName = getValueType().getTableName();
    403             org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(
     403            org.hibernate.query.Query<?> update = HibernateUtil.getPredefinedSQLQuery(
    404404              getDbControl().getHibernateSession(),
    405405              "RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE", tableName);
     
    413413              )
    414414            */
    415             query.setDouble("factor", factor);
    416             query.setDouble("offset", offset);
    417             query.setInteger("annotationType", getId());
    418             HibernateUtil.executeUpdate(query);
     415            update.setParameter("factor", factor, TypeWrapper.H_DOUBLE);
     416            update.setParameter("offset", offset, TypeWrapper.H_DOUBLE);
     417            update.setParameter("annotationType", getId(), TypeWrapper.H_INTEGER);
     418            HibernateUtil.executeUpdate(update);
    419419           
    420420            // We also need to invalidate all annotation set snapshots that
    421421            // include this annotation type
    422             query = HibernateUtil.createQuery(getDbControl().getHibernateSession(),
    423               "SELECT a.annotationSet " +
     422            org.hibernate.query.Query<Integer> query = HibernateUtil.createQuery(getDbControl().getHibernateSession(),
     423              "SELECT a.annotationSet.id " +
    424424              "FROM AnnotationData a " +
    425               "WHERE a.annotationType = :annotationType");
    426             query.setInteger("annotationType", getId());
    427             List<AnnotationSetData> tmp = HibernateUtil.loadList(AnnotationSetData.class, query, getSessionControl());
    428             for (AnnotationSetData as : tmp)
    429             {
    430               SnapshotManager.removeSnapshot(as.getId());
    431             }
     425              "WHERE a.annotationType = :annotationType", Integer.class);
     426            query.setParameter("annotationType", getId(), TypeWrapper.H_INTEGER);
     427            List<Integer> tmp = HibernateUtil.loadList(query, getSessionControl());
     428            SnapshotManager.removeSnapshots(tmp);
    432429          }
    433430        }
     
    10511048    org.hibernate.query.Query<Long> query = HibernateUtil.getPredefinedQuery(getDbControl().getHibernateSession(),
    10521049      "COUNT_PROJECT_ANNOTATIONS_FOR_ANNOTATIONTYPE", Long.class);
    1053     query.setInteger("annotationType", getId());
     1050    query.setParameter("annotationType", getId(), TypeWrapper.H_INTEGER);
    10541051    long count = HibernateUtil.loadData(query);
    10551052    return count;
     
    15691566        org.hibernate.Session session = dc.getHibernateSession();
    15701567       
    1571         org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(session, "LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE");
    1572         query.setInteger("annotationType", at.getId());
    1573         List<Integer> ids = HibernateUtil.loadList(Integer.class, query, dc.getSessionControl());
     1568        org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedSQLQuery(session,
     1569          "LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE", Integer.class);
     1570        query.setParameter("annotationType", at.getId(), TypeWrapper.H_INTEGER);
     1571        List<Integer> ids = HibernateUtil.loadList(query, dc.getSessionControl());
    15741572        SnapshotManager.removeSnapshots(ids);
    15751573       
    1576         query = HibernateUtil.getPredefinedSQLQuery(session, "DELETE_INHERITED_ANNOTATIONS");
    1577         query.setInteger("annotationType", at.getId());
    1578         query.executeUpdate();
     1574        org.hibernate.query.Query<?> update = HibernateUtil.getPredefinedSQLQuery(session, "DELETE_INHERITED_ANNOTATIONS");
     1575        update.setParameter("annotationType", at.getId(), TypeWrapper.H_INTEGER);
     1576        update.executeUpdate();
    15791577      }
    15801578    }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AnyToAny.java

    r7372 r7374  
    151151  {
    152152    name = name.trim();
    153     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    154       "GET_ANYTOANY_FOR_NAME");
     153    org.hibernate.query.Query<AnyToAnyData> query = HibernateUtil.getPredefinedQuery(session,
     154      "GET_ANYTOANY_FOR_NAME", AnyToAnyData.class);
    155155    /*
    156156      SELECT ata
     
    158158      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
    159159    */
    160     query.setInteger("fromId", fromId);
    161     query.setInteger("fromType", fromType.getValue());
    162     query.setString("name", name);
    163     AnyToAnyData ata = HibernateUtil.loadData(AnyToAnyData.class, query);
     160    query.setParameter("fromId", fromId, TypeWrapper.H_INTEGER);
     161    query.setParameter("fromType", fromType.getValue(), TypeWrapper.H_INTEGER);
     162    query.setParameter("name", name, TypeWrapper.H_STRING);
     163    AnyToAnyData ata = HibernateUtil.loadData(query);
    164164    return ata;
    165165  }
     
    267267    if (name == null) throw new InvalidUseOfNullException("name");
    268268    from.checkPermission(Permission.WRITE);
    269     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     269    org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
    270270      "DELETE_ANYTOANY_FROM");
    271271    /*
     
    273273      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
    274274    */
    275     query.setInteger("fromId", from.getId());
    276     query.setInteger("fromType", from.getType().getValue());
    277     query.setString("name", name);
     275    query.setParameter("fromId", from.getId(), TypeWrapper.H_INTEGER);
     276    query.setParameter("fromType", from.getType().getValue(), TypeWrapper.H_INTEGER);
     277    query.setParameter("name", name, TypeWrapper.H_STRING);
    278278    HibernateUtil.executeUpdate(query);
    279279  }
     
    297297    from.checkPermission(Permission.WRITE);
    298298
    299     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     299    org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
    300300      "DELETE_ALL_ANYTOANY_FROM");
    301301    /*
     
    303303      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
    304304    */
    305     query.setInteger("fromId", from.getId());
    306     query.setInteger("fromType", from.getType().getValue());
     305    query.setParameter("fromId", from.getId(), TypeWrapper.H_INTEGER);
     306    query.setParameter("fromType", from.getType().getValue(), TypeWrapper.H_INTEGER);
    307307    return HibernateUtil.executeUpdate(query);
    308308  }
     
    327327    if (name == null) throw new InvalidUseOfNullException("name");
    328328    name = name.trim();
    329     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
    330       "GET_ANYTOANY_FOR_NAME");
     329    org.hibernate.query.Query<AnyToAnyData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     330      "GET_ANYTOANY_FOR_NAME", AnyToAnyData.class);
    331331    /*
    332332      SELECT ata
     
    334334      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
    335335    */
    336     query.setInteger("fromId", from.getId());
    337     query.setInteger("fromType", from.getType().getValue());
    338     query.setString("name", name);
    339     AnyToAny ata = dc.getItem(AnyToAny.class, HibernateUtil.loadData(AnyToAnyData.class, query));
     336    query.setParameter("fromId", from.getId(), TypeWrapper.H_INTEGER);
     337    query.setParameter("fromType", from.getType().getValue(), TypeWrapper.H_INTEGER);
     338    query.setParameter("name", name, TypeWrapper.H_STRING);
     339    AnyToAny ata = dc.getItem(AnyToAny.class, HibernateUtil.loadData(query));
    340340    return ata != null;
    341341  }
     
    366366        progress.display(5, "Finding item types used by any-to-any links...");
    367367      }
    368       org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(session,
    369           "FIND_USED_TYPES_IN_ANYTOANY");
     368      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedSQLQuery(session,
     369          "FIND_USED_TYPES_IN_ANYTOANY", Integer.class);
    370370      /*
    371371        -- NOTE! UNION produces a distinct result by default (which is what we want)
     
    374374        SELECT [a].[to_type] FROM [AnyToAny] [a]
    375375      */
    376       List<Integer> itemTypes = HibernateUtil.loadList(Integer.class, query, null);
     376      List<Integer> itemTypes = HibernateUtil.loadList(query, null);
    377377     
    378378      // For each item type: find and delete non-existing items
     
    380380      int numItemTypes = itemTypes.size();
    381381      int maxParameters = HibernateUtil.getDbEngine().getMaxParametersInQuery();
    382       org.hibernate.query.Query deleteQuery =
     382      org.hibernate.query.Query<?> deleteQuery =
    383383        HibernateUtil.getPredefinedQuery(session, "DELETE_STRAY_ANYTOANY");
    384384      for (int itemType : itemTypes)
     
    395395     
    396396        query = HibernateUtil.getPredefinedSQLQuery(session, "SELECT_STRAY_ANYTOANY",
    397             table.getName());
     397            Integer.class, table.getName());
    398398        /*
    399399          SELECT [a].[id]
     
    404404          WHERE [t].[id] is null AND ([a].[from_type = :type OR [a].[to_type] = :type)
    405405        */
    406         query.setInteger("type", itemType);
     406        query.setParameter("type", itemType, TypeWrapper.H_INTEGER);
    407407       
    408         List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     408        List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(query, null));
    409409        int startIndex = 0;
    410410        int endIndex = Math.min(maxParameters, stray.size());
    411411        while (startIndex < stray.size())
    412412        {
    413           deleteQuery.setParameterList("ids", stray.subList(startIndex, endIndex), TypeWrapper.INTEGER.getHibernateType());
     413          deleteQuery.setParameterList("ids", stray.subList(startIndex, endIndex), TypeWrapper.H_INTEGER);
    414414          numDeleted += HibernateUtil.executeUpdate(deleteQuery);
    415415          startIndex = endIndex;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Application.java

    r7373 r7374  
    2626
    2727import net.sf.basedb.core.data.SchemaVersionData;
     28import net.sf.basedb.core.hibernate.TypeWrapper;
    2829import net.sf.basedb.util.EmailUtil;
    2930import net.sf.basedb.util.FileUtil;
     
    273274        org.hibernate.query.Query<SchemaVersionData> query = HibernateUtil.getPredefinedQuery(session,
    274275          "GET_SCHEMA_VERSION_FOR_APP", SchemaVersionData.class);
    275         query.setString("appId", SchemaVersionData.BASE_APP_ID);
     276        query.setParameter("appId", SchemaVersionData.BASE_APP_ID, TypeWrapper.H_STRING);
    276277        schemaVersion = HibernateUtil.loadData(query).getSchemaVersion();
    277278        HibernateUtil.commit(tx);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ArraySlide.java

    r7373 r7374  
    2525import net.sf.basedb.core.data.ArraySlideData;
    2626import net.sf.basedb.core.data.PhysicalBioAssayData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728
    2829import java.util.Date;
     
    119120      WHERE ars.barcode = :barcode
    120121    */
    121     query.setString("barcode", barcode);
     122    query.setParameter("barcode", barcode, TypeWrapper.H_STRING);
    122123    return HibernateUtil.loadData(query) > 0;
    123124  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/AuthenticationContext.java

    r7372 r7374  
    2727import net.sf.basedb.core.authentication.LoginRequest;
    2828import net.sf.basedb.core.data.UserData;
     29import net.sf.basedb.core.hibernate.TypeWrapper;
    2930import net.sf.basedb.core.query.QueryParameter;
    3031import net.sf.basedb.util.extensions.ClientContext;
     
    6667  public UserData getUserByLogin(String login)
    6768  {
    68     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN");
     69    org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session,
     70      "GET_USER_FOR_LOGIN", UserData.class);
    6971    /*
    7072      SELECT usr
     
    7274      WHERE usr.login = :login
    7375    */
    74     query.setString("login", login);
    75     return HibernateUtil.loadData(UserData.class, query);
     76    query.setParameter("login", login, TypeWrapper.H_STRING);
     77    return HibernateUtil.loadData(query);
    7678  }
    7779 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/BasicItem.java

    r7373 r7374  
    2525import net.sf.basedb.core.data.AnnotatableData;
    2626import net.sf.basedb.core.data.BasicData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728
    2829import java.lang.ref.WeakReference;
     
    228229      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
    229230    */
    230     query.setInteger("toId", this.getId());
    231     query.setInteger("toType", this.getType().getValue());
     231    query.setParameter("toId", this.getId(), TypeWrapper.H_INTEGER);
     232    query.setParameter("toType", this.getType().getValue(), TypeWrapper.H_INTEGER);
    232233    return HibernateUtil.loadData(query) > 0;
    233234  }
     
    258259      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
    259260    */
    260     query.setInteger("toId", this.getId());
    261     query.setInteger("toType", this.getType().getValue());
     261    query.setParameter("toId", this.getId(), TypeWrapper.H_INTEGER);
     262    query.setParameter("toType", this.getType().getValue(), TypeWrapper.H_INTEGER);
    262263    Set<ItemProxy> using = new TreeSet<ItemProxy>();
    263264    for (Object[] u : HibernateUtil.loadList(query, getSessionControl()))
     
    509510      // ...and all links to this item that doesn't count as using it
    510511      org.hibernate.Session session = getDbControl().getHibernateSession();
    511       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
     512      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session,
    512513        "DELETE_UNUSED_ANYTOANY_TO");
    513514      /*
     
    515516        WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
    516517      */
    517       query.setInteger("toId", this.getId());
    518       query.setInteger("toType", this.getType().getValue());
     518      query.setParameter("toId", this.getId(), TypeWrapper.H_INTEGER);
     519      query.setParameter("toType", this.getType().getValue(), TypeWrapper.H_INTEGER);
    519520      HibernateUtil.executeUpdate(query);
    520521     
     
    534535            )
    535536          */
    536         query.setInteger("delta", -1);
    537         query.setInteger("itemId", getId());
    538         query.setInteger("memberType", getType().getValue());
     537        query.setParameter("delta", -1, TypeWrapper.H_INTEGER);
     538        query.setParameter("itemId", getId(), TypeWrapper.H_INTEGER);
     539        query.setParameter("memberType", getType().getValue(), TypeWrapper.H_INTEGER);
    539540        int numUpdated = HibernateUtil.executeUpdate(query);
    540541        if (numUpdated > 0)
     
    552553              )
    553554            */
    554           query.setInteger("itemId", getId());
    555           query.setInteger("memberType", getType().getValue());
     555          query.setParameter("itemId", getId(), TypeWrapper.H_INTEGER);
     556          query.setParameter("memberType", getType().getValue(), TypeWrapper.H_INTEGER);
    556557          int numMembers = query.executeUpdate();
    557558        }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ChangeHistory.java

    r7372 r7374  
    182182        progress.display(5, "Finding item types with history...");
    183183      }
    184       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    185           "FIND_USED_TYPES_IN_CHANGEHISTORY");
     184      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session,
     185          "FIND_USED_TYPES_IN_CHANGEHISTORY", Integer.class);
    186186      /*
    187187        SELECT DISTINCT ch.itemType
    188188        FROM ChangeHistoryDetailData ch
    189189      */
    190       List<Integer> itemTypes = HibernateUtil.loadList(Integer.class, query, null);
     190      List<Integer> itemTypes = HibernateUtil.loadList(query, null);
    191191     
    192192      // For each item type: find and delete entries which reference non-existing items
     
    194194      int numItemTypes = itemTypes.size();
    195195      int maxParameters = HibernateUtil.getDbEngine().getMaxParametersInQuery();
    196       org.hibernate.query.Query deleteQuery =
     196      org.hibernate.query.Query<?> deleteQuery =
    197197        HibernateUtil.getPredefinedQuery(session, "DELETE_STRAY_CHANGEHISTORY");
    198198      for (int itemType : itemTypes)
     
    208208        Table table = pClass.getTable();
    209209     
    210         query = HibernateUtil.getPredefinedSQLQuery(session, "SELECT_STRAY_CHANGEHISTORY",
     210        query = HibernateUtil.getPredefinedSQLQuery(session, "SELECT_STRAY_CHANGEHISTORY", Integer.class,
    211211            table.getName());
    212212        /*
     
    218218          AND [ch].[item_type] = :type
    219219        */
    220         query.setInteger("type", itemType);
    221         List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     220        query.setParameter("type", itemType, TypeWrapper.H_INTEGER);
     221        List<Integer> stray = new ArrayList<Integer>(HibernateUtil.loadList(query, null));
    222222        int startIndex = 0;
    223223        int endIndex = Math.min(maxParameters, stray.size());
    224224        while (startIndex < stray.size())
    225225        {
    226           deleteQuery.setParameterList("ids", stray.subList(startIndex, endIndex), TypeWrapper.INTEGER.getHibernateType());
     226          deleteQuery.setParameterList("ids", stray.subList(startIndex, endIndex), TypeWrapper.H_INTEGER);
    227227          numDeleted += HibernateUtil.executeUpdate(deleteQuery);
    228228          startIndex = endIndex;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Client.java

    r7373 r7374  
    2828import net.sf.basedb.core.data.ClientData;
    2929import net.sf.basedb.core.data.HelpData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3031import net.sf.basedb.core.query.Restrictions;
    3132import net.sf.basedb.core.query.Expressions;
     
    127128      WHERE cli.externalId = :externalId
    128129    */
    129     query.setString("externalId", externalId);
     130    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    130131    Client c = dc.getItem(Client.class, HibernateUtil.loadData(query));
    131132    if (c == null) throw new ItemNotFoundException("Client[externalId="+externalId+"]");
     
    317318      WHERE hlp.externalId = :externalId AND hlp.client = :client
    318319    */
    319     query.setString("externalId", externalId);
     320    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    320321    query.setEntity("client", getData());
    321322    Help h = dc.getItem(Help.class, HibernateUtil.loadData(query));
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/DataCube.java

    r7373 r7374  
    2828import net.sf.basedb.core.data.DataCubeData;
    2929import net.sf.basedb.core.data.SharedData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3031import net.sf.basedb.core.query.Aggregations;
    3132import net.sf.basedb.core.query.Dynamic;
     
    189190      */
    190191      org.hibernate.Session session = getDbControl().getHibernateSession();
    191       org.hibernate.query.Query query =
     192      org.hibernate.query.Query<?> query =
    192193        HibernateUtil.getPredefinedQuery(session, "UPDATE_BYTES_FOR_DATACUBE");
    193194      /*
     
    197198      */
    198199      query.setLong("addedBytes", addedBytes);
    199       query.setInteger("dataCube", getId());
     200      query.setParameter("dataCube", getId(), TypeWrapper.H_INTEGER);
    200201      query.executeUpdate();
    201202      addedBytes = 0;
     
    324325          WHERE dcb.id = :dataCube
    325326        */
    326         update.setInteger("dataCube", this.getId());
     327        update.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    327328        HibernateUtil.executeUpdate(update);
    328329       
     
    335336          WHERE dcb.id = :dataCube
    336337        */
    337         query.setInteger("dataCube", this.getId());
     338        query.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    338339        filterNo = HibernateUtil.loadData(query);
    339340        HibernateUtil.commit(tx);
     
    397398          WHERE dcb.id = :dataCube
    398399        */
    399         update.setInteger("dataCube", this.getId());
     400        update.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    400401        HibernateUtil.executeUpdate(update);
    401402       
     
    408409          WHERE dcb.id = :dataCube
    409410        */
    410         query.setInteger("dataCube", this.getId());
     411        query.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    411412        extraNo = HibernateUtil.loadData(query);
    412413        HibernateUtil.commit(tx);
     
    467468          WHERE dcb.id = :dataCube
    468469        */
    469         update.setInteger("dataCube", this.getId());
     470        update.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    470471        HibernateUtil.executeUpdate(update);
    471472       
     
    478479          WHERE dcb.id = :dataCube
    479480        */
    480         query.setInteger("dataCube", this.getId());
     481        query.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    481482        layerNo = HibernateUtil.loadData(query);
    482483        HibernateUtil.commit(tx);
     
    538539          WHERE dcb.id = :dataCube
    539540        */
    540         update.setInteger("dataCube", this.getId());
     541        update.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    541542        HibernateUtil.executeUpdate(update);
    542543       
     
    549550          WHERE dcb.id = :dataCube
    550551        */
    551         query.setInteger("dataCube", this.getId());
     552        query.setParameter("dataCube", this.getId(), TypeWrapper.H_INTEGER);
    552553        columnNo = HibernateUtil.loadData(query);
    553554        HibernateUtil.commit(tx);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/DataFileType.java

    r7373 r7374  
    2525
    2626import net.sf.basedb.core.data.DataFileTypeData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728import net.sf.basedb.core.query.Expressions;
    2829import net.sf.basedb.core.query.Hql;
     
    234235      WHERE dft.externalId = :externalId
    235236    */
    236     query.setString("externalId", externalId);
     237    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    237238    DataFileType dft = dc.getItem(DataFileType.class, HibernateUtil.loadData(query));
    238239    if (dft == null) throw new ItemNotFoundException("DataFileType[externalId="+externalId+"]");
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/DbControl.java

    r7373 r7374  
    3434import net.sf.basedb.core.hibernate.SessionWrapper;
    3535import net.sf.basedb.core.hibernate.StatelessSessionWrapper;
     36import net.sf.basedb.core.hibernate.TypeWrapper;
    3637import net.sf.basedb.core.log.LogManagerFactory;
    3738import net.sf.basedb.core.log.LoggingInterceptor;
     
    728729    }
    729730    query.setEntity("user", user);
    730     query.setInteger("location", location.getValue());
    731     Long bytes = HibernateUtil.loadData(Long.class, query);
     731    query.setParameter("location", location.getValue(), TypeWrapper.H_INTEGER);
     732    Long bytes = HibernateUtil.loadData(query);
    732733    return bytes == null ? 0 : bytes;
    733734  }
     
    768769    }
    769770    query.setEntity("group", group);
    770     query.setInteger("location", location.getValue());
    771     Long bytes = HibernateUtil.loadData(Long.class, query);
     771    query.setParameter("location", location.getValue(), TypeWrapper.H_INTEGER);
     772    Long bytes = HibernateUtil.loadData(query);
    772773    return bytes == null ? 0 : bytes;
    773774  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Directory.java

    r7373 r7374  
    2525
    2626import net.sf.basedb.core.data.UserData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728import net.sf.basedb.core.data.DirectoryData;
    2829import net.sf.basedb.core.query.Hql;
     
    151152    Map<String, Directory> directoryCache = null;
    152153   
    153     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    154         dc.getHibernateSession(), "GET_SUBDIRECTORY_WITH_NAME");
     154    org.hibernate.query.Query<DirectoryData> query = HibernateUtil.getPredefinedQuery(
     155        dc.getHibernateSession(), "GET_SUBDIRECTORY_WITH_NAME", DirectoryData.class);
    155156    /*
    156157      SELECT dir
     
    165166      if (!creating)
    166167      {
    167         query.setInteger("parent", currentDirId);
    168         query.setString("name", subDirName);
    169         DirectoryData subDir = HibernateUtil.loadData(DirectoryData.class, query);
     168        query.setParameter("parent", currentDirId, TypeWrapper.H_INTEGER);
     169        query.setParameter("name", subDirName, TypeWrapper.H_STRING);
     170        DirectoryData subDir = HibernateUtil.loadData(query);
    170171        if (subDir != null)
    171172        {
     
    297298      else
    298299      {
    299         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_USER_FOR_LOGIN");
    300         query.setString("login", path.getUserLogin());
    301         userData = HibernateUtil.loadData(UserData.class, query);
     300        org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     301          "GET_USER_FOR_LOGIN", UserData.class);
     302        query.setParameter("login", path.getUserLogin(), TypeWrapper.H_STRING);
     303        userData = HibernateUtil.loadData(query);
    302304        if (userData == null)
    303305        {
     
    312314    }
    313315    if (current == null) throw new ItemNotFoundException("Directory[path="+path+"]");
    314     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SUBDIRECTORY_WITH_NAME");
     316    org.hibernate.query.Query<DirectoryData> query = HibernateUtil.getPredefinedQuery(session,
     317      "GET_SUBDIRECTORY_WITH_NAME", DirectoryData.class);
    315318    for (int i = 0; i < path.getDirectoryCount(); i++)
    316319    {
    317320      query.setEntity("parent", current);
    318       query.setString("name", path.getDirectory(i));
    319       current = HibernateUtil.loadData(DirectoryData.class, query);
     321      query.setParameter("name", path.getDirectory(i), TypeWrapper.H_STRING);
     322      current = HibernateUtil.loadData(query);
    320323      if (current == null)
    321324      {
     
    341344  {
    342345    if (subdirectoryName != null) subdirectoryName = subdirectoryName.trim();
    343     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_SUBDIRECTORY_WITH_NAME");
     346    org.hibernate.query.Query<DirectoryData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     347      "GET_SUBDIRECTORY_WITH_NAME", DirectoryData.class);
    344348    /*
    345349      SELECT dir
     
    348352      AND dir.parent = :parent
    349353    */
    350     query.setInteger("parent", directory.getData().getId());
    351     query.setString("name", subdirectoryName);
    352     DirectoryData subdirectory = HibernateUtil.loadData(DirectoryData.class, query);
     354    query.setParameter("parent", directory.getData().getId(), TypeWrapper.H_INTEGER);
     355    query.setParameter("name", subdirectoryName, TypeWrapper.H_STRING);
     356    DirectoryData subdirectory = HibernateUtil.loadData(query);
    353357    return subdirectory != null;
    354358  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/DiskUsageStatistics.java

    r7372 r7374  
    2929import java.util.Map;
    3030
     31import net.sf.basedb.core.hibernate.TypeWrapper;
    3132import net.sf.basedb.core.query.Expressions;
    3233import net.sf.basedb.core.query.Hql;
     
    194195    {
    195196      diskUsage = new HashMap<String, Long>();
    196       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
    197         "GET_TOTAL_DISKUSAGE_SUMMARY");
     197      org.hibernate.query.Query<Object[]> query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
     198        "GET_TOTAL_DISKUSAGE_SUMMARY", Object[].class);
    198199      /*
    199200        SELECT SUM(du.bytes), du.location, du.quotaType.systemId
     
    206207    {
    207208      diskUsage = new HashMap<String, Long>();
    208       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
    209         "GET_DISKUSAGE_SUMMARY_FOR_USER");
     209      org.hibernate.query.Query<Object[]> query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
     210        "GET_DISKUSAGE_SUMMARY_FOR_USER", Object[].class);
    210211      /*
    211212        SELECT SUM(du.bytes), du.location, du.quotaType.systemId
     
    214215        GROUP BY du.location, du.quotaType.systemId
    215216      */
    216       query.setInteger("user", user.getId());
     217      query.setParameter("user", user.getId(), TypeWrapper.H_INTEGER);
    217218      loadDiskUsage(query);
    218219    }
     
    221222    {
    222223      diskUsage = new HashMap<String, Long>();
    223       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
    224         "GET_DISKUSAGE_SUMMARY_FOR_GROUP");
     224      org.hibernate.query.Query<Object[]> query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(),
     225        "GET_DISKUSAGE_SUMMARY_FOR_GROUP", Object[].class);
    225226      /*
    226227        SELECT SUM(du.bytes), du.location, du.quotaType.systemId
     
    229230        GROUP BY du.location, du.quotaType.systemId
    230231      */
    231       query.setInteger("group", group.getId());
     232      query.setParameter("group", group.getId(), TypeWrapper.H_INTEGER);
    232233      loadDiskUsage(query);   
    233234    }
    234235   
    235     private void loadDiskUsage(org.hibernate.query.Query query)
    236     {
    237       List<Object[]> du = HibernateUtil.loadList(Object[].class, query, null);
     236    private void loadDiskUsage(org.hibernate.query.Query<Object[]> query)
     237    {
     238      List<Object[]> du = HibernateUtil.loadList(query, null);
    238239      for (Object[] row : du)
    239240      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Experiment.java

    r7372 r7374  
    301301      */
    302302      org.hibernate.Session session = getDbControl().getHibernateSession();
    303       org.hibernate.query.Query query =
     303      org.hibernate.query.Query<?> query =
    304304        HibernateUtil.getPredefinedQuery(session, "UPDATE_BYTES_FOR_EXPERIMENT");
    305305      /*
     
    309309      */
    310310      query.setLong("addedBytes", addedBytes - updatedBytes);
    311       query.setInteger("experiment", getId());
     311      query.setParameter("experiment", getId(), TypeWrapper.H_INTEGER);
    312312      query.executeUpdate();
    313313      updatedBytes = addedBytes;
     
    928928        WHERE job.id IN (:list)
    929929      */
    930       query.setParameterList("list", jobs, TypeWrapper.INTEGER.getHibernateType());
     930      query.setParameterList("list", jobs, TypeWrapper.H_INTEGER);
    931931      HibernateUtil.executeUpdate(query);
    932932    }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ExtraValueType.java

    r7373 r7374  
    2929import net.sf.basedb.core.Formula.AverageMethod;
    3030import net.sf.basedb.core.data.ExtraValueTypeData;
     31import net.sf.basedb.core.hibernate.TypeWrapper;
    3132
    3233
     
    131132    org.hibernate.query.Query<ExtraValueTypeData> query = HibernateUtil.getPredefinedQuery(session,
    132133      "GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID", ExtraValueTypeData.class);
    133     query.setString("externalId", externalId);
     134    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    134135    ExtraValueType evt = dc.getItem(ExtraValueType.class, HibernateUtil.loadData(query));
    135136    if (evt == null) throw new ItemNotFoundException("ExtraValueType[externalId="+externalId+"]");
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/File.java

    r7373 r7374  
    3030import net.sf.basedb.core.data.ItemSubtypeData;
    3131import net.sf.basedb.core.data.MimeTypeData;
     32import net.sf.basedb.core.hibernate.TypeWrapper;
    3233import net.sf.basedb.util.EqualsHelper;
    3334import net.sf.basedb.util.FileUtil;
     
    256257      throw new ItemNotFoundException("File[path="+path+"]");
    257258    }
    258     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_FILE_IN_DIRECTORY");
     259    org.hibernate.query.Query<FileData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     260      "GET_FILE_IN_DIRECTORY", FileData.class);
    259261    /*
    260262      SELECT f
     
    263265      AND f.name = :name
    264266    */
    265     query.setInteger("directory", directoryId);
    266     query.setString("name", path.getFilename());
    267     FileData fileData = HibernateUtil.loadData(FileData.class, query);
     267    query.setParameter("directory", directoryId, TypeWrapper.H_INTEGER);
     268    query.setParameter("name", path.getFilename(), TypeWrapper.H_STRING);
     269    FileData fileData = HibernateUtil.loadData(query);
    268270   
    269271    if (fileData == null)
     
    315317      throw new InvalidUseOfNullException("directory");
    316318    }
    317     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_FILE_IN_DIRECTORY");
     319    org.hibernate.query.Query<FileData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     320      "GET_FILE_IN_DIRECTORY", FileData.class);
    318321    /*
    319322      SELECT f
     
    322325      AND f.name = :name
    323326    */
    324     query.setInteger("directory", directory.getId());
    325     query.setString("name", fileName);
    326     FileData fileData = HibernateUtil.loadData(FileData.class, query);
     327    query.setParameter("directory", directory.getId(), TypeWrapper.H_INTEGER);
     328    query.setParameter("name", fileName, TypeWrapper.H_STRING);
     329    FileData fileData = HibernateUtil.loadData(query);
    327330   
    328331    if (fileData == null)
     
    358361  {
    359362    if (fileName != null) fileName = fileName.trim();
    360     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_FILE_IN_DIRECTORY");
     363    org.hibernate.query.Query<FileData> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     364      "GET_FILE_IN_DIRECTORY", FileData.class);
    361365    /*
    362366      SELECT f
     
    365369      AND f.name = :name
    366370    */
    367     query.setInteger("directory", directory.getData().getId());
    368     query.setString("name", fileName);
    369     FileData file = HibernateUtil.loadData(FileData.class, query);
     371    query.setParameter("directory", directory.getData().getId(), TypeWrapper.H_INTEGER);
     372    query.setParameter("name", fileName, TypeWrapper.H_STRING);
     373    FileData file = HibernateUtil.loadData(query);
    370374    return file != null;
    371375  }
     
    12141218          WHERE mt.extension = :extension
    12151219        */
    1216         query.setString("extension", extension);
     1220        query.setParameter("extension", extension, TypeWrapper.H_STRING);
    12171221        MimeTypeData mimeType = HibernateUtil.loadData(query);
    12181222        ItemSubtypeData fileType = null;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/FileStoreUtil.java

    r7372 r7374  
    3030import net.sf.basedb.core.data.DataFileTypeData;
    3131import net.sf.basedb.core.data.FileSetMemberData;
     32import net.sf.basedb.core.hibernate.TypeWrapper;
    3233import net.sf.basedb.core.query.Expressions;
    3334import net.sf.basedb.core.query.Hql;
     
    6061  {
    6162    if (item == null || !item.hasFileSet()) return false;
    62     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    63       dc.getHibernateSession(), "GET_FILESETMEMBER_FOR_DATAFILETYPE");
     63    org.hibernate.query.Query<FileSetMemberData> query = HibernateUtil.getPredefinedQuery(
     64      dc.getHibernateSession(), "GET_FILESETMEMBER_FOR_DATAFILETYPE", FileSetMemberData.class);
    6465    /*
    6566      SELECT mbr
     
    6869      AND mbr.fileSet = :fileSet
    6970    */
    70     query.setString("externalId", dataFileType);
    71     query.setInteger("fileSet", item.getFileSet().getId());
    72     FileSetMemberData member = HibernateUtil.loadData(FileSetMemberData.class, query);
     71    query.setParameter("externalId", dataFileType, TypeWrapper.H_STRING);
     72    query.setParameter("fileSet", item.getFileSet().getId(), TypeWrapper.H_INTEGER);
     73    FileSetMemberData member = HibernateUtil.loadData(query);
    7374    // The file doesn't exists
    7475    if (member == null) return false;
     
    104105    if (item != null && item.hasFileSet())
    105106    {
    106       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    107         dc.getHibernateSession(), "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
    108       query.setString("externalId", dataFileType);
    109       DataFileTypeData dft = HibernateUtil.loadData(DataFileTypeData.class, query);
     107      org.hibernate.query.Query<DataFileTypeData> query = HibernateUtil.getPredefinedQuery(
     108        dc.getHibernateSession(), "GET_DATAFILETYPE_FOR_EXTERNAL_ID", DataFileTypeData.class);
     109      query.setParameter("externalId", dataFileType, TypeWrapper.H_STRING);
     110      DataFileTypeData dft = HibernateUtil.loadData(query);
    110111      if (dft != null)
    111112      {
     
    146147    if (item != null && item.hasFileSet())
    147148    {
    148       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    149         dc.getHibernateSession(), "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
    150       query.setString("externalId", dataFileType);
    151       DataFileTypeData dft = HibernateUtil.loadData(DataFileTypeData.class, query);
     149      org.hibernate.query.Query<DataFileTypeData> query = HibernateUtil.getPredefinedQuery(
     150        dc.getHibernateSession(), "GET_DATAFILETYPE_FOR_EXTERNAL_ID", DataFileTypeData.class);
     151      query.setParameter("externalId", dataFileType, TypeWrapper.H_STRING);
     152      DataFileTypeData dft = HibernateUtil.loadData(query);
    152153      if (dft != null)
    153154      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Group.java

    r7373 r7374  
    150150      do
    151151      {
    152         query.setParameterList("groups", allGroups, TypeWrapper.INTEGER.getHibernateType());
     152        query.setParameterList("groups", allGroups, TypeWrapper.H_INTEGER);
    153153      } while (allGroups.addAll(HibernateUtil.loadList(Integer.class, query, null)));
    154154    }
     
    291291    if (action == Transactional.Action.DELETE)
    292292    {
    293       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
     293      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(
    294294          getDbControl().getHibernateSession(), "SET_GROUP_TO_NULL_ON_DISK_USAGE");
    295295      /*
     
    298298        WHERE [group] = :group
    299299      */
    300       query.setInteger("group", getId());
     300      query.setParameter("group", getId(), TypeWrapper.H_INTEGER);
    301301      HibernateUtil.executeUpdate(query);     
    302302    }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/HibernateUtil.java

    r7373 r7374  
    19311931    }
    19321932  }
     1933 
     1934  /**
     1935    Create a Hibernate SQL query with a known return type.
     1936    @since 3.12
     1937  */
     1938  static <R> NativeQuery<R> createSqlQuery(Session session, String sql, Class<R> returnType)
     1939    throws BaseException
     1940  {
     1941    assert session != null : "session == null";
     1942    assert sql != null : "sql == null";
     1943    sql = sql.replace('[', getDialect().openQuote()).replace(']', getDialect().closeQuote());
     1944    try
     1945    {
     1946      NativeQuery<R> q = session.createNativeQuery(sql, returnType);
     1947      ((Query<R>)q).setFetchSize(getJdbcFetchSize());
     1948      return q;
     1949    }
     1950    catch (HibernateException ex)
     1951    {
     1952      throw new BaseException(ex);
     1953    }
     1954  }
    19331955
    19341956  /**
     
    19531975  }
    19541976 
     1977  /**
     1978    Create a Hibernate SQL query with a known return type using a stateless session.
     1979    @since 3.12
     1980  */
     1981  static <R> NativeQuery<R> createSqlQuery(StatelessSession session, String sql, Class<R> returnType)
     1982    throws BaseException
     1983  {
     1984    assert session != null : "session == null";
     1985    assert sql != null : "sql == null";
     1986    sql = sql.replace('[', getDialect().openQuote()).replace(']', getDialect().closeQuote());
     1987    try
     1988    {
     1989      NativeQuery<R> q = session.createNativeQuery(sql, returnType);
     1990      ((Query<R>)q).setFetchSize(getJdbcFetchSize());
     1991      return q;
     1992    }
     1993    catch (HibernateException ex)
     1994    {
     1995      throw new BaseException(ex);
     1996    }
     1997  }
     1998
    19551999  /**
    19562000    Enable the filter with the given name.
     
    21562200 
    21572201  /**
     2202    Get a predefined SQL query with a known return type.
     2203    @see PredefinedQuery
     2204    @since 3.12
     2205  */
     2206  static <R> Query<R> getPredefinedSQLQuery(Session session, String name, Class<R> returnType, String... replacements)
     2207    throws BaseException
     2208  {
     2209    assert session != null : "session == null";
     2210    assert name != null : "name == null";
     2211    return createSqlQuery(session, PredefinedQuery.getQueryString(name, replacements), returnType);
     2212  }
     2213
     2214  /**
    21582215    Get a predefined SQL query using the stateless session.
    21592216    @see PredefinedQuery
     
    21672224  }
    21682225 
     2226  /**
     2227    Get a predefined SQL query with a known return type using the stateless session.
     2228    @see PredefinedQuery
     2229  */
     2230  static <R> NativeQuery<R> getPredefinedSQLQuery(StatelessSession session, String name, Class<R> returnType)
     2231    throws BaseException
     2232  {
     2233    assert session != null : "session == null";
     2234    assert name != null : "name == null";
     2235    return createSqlQuery(session, PredefinedQuery.getQueryString(name), returnType);
     2236  }
     2237
    21692238  static Iterator<PersistentClass> getClassMappings()
    21702239  {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Install.java

    r7373 r7374  
    6565import net.sf.basedb.core.data.PluginTypeData;
    6666import net.sf.basedb.core.hibernate.SchemaGenerator;
     67import net.sf.basedb.core.hibernate.TypeWrapper;
    6768import net.sf.basedb.core.SessionControl;
    6869import net.sf.basedb.core.DbControl;
     
    10051006      tx = HibernateUtil.newTransaction(session);
    10061007
    1007       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SCHEMA_VERSION_FOR_APP");
    1008       query.setString("appId", SchemaVersionData.BASE_APP_ID);
    1009       schemaVersion = HibernateUtil.loadData(SchemaVersionData.class, query);
     1008      org.hibernate.query.Query<SchemaVersionData> query = HibernateUtil.getPredefinedQuery(session,
     1009        "GET_SCHEMA_VERSION_FOR_APP", SchemaVersionData.class);
     1010      query.setParameter("appId", SchemaVersionData.BASE_APP_ID, TypeWrapper.H_STRING);
     1011      schemaVersion = HibernateUtil.loadData(query);
    10101012      if (schemaVersion != null)
    10111013      {
     
    10511053      if (directory == null && parent != null)
    10521054      {
    1053         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SUBDIRECTORY_WITH_NAME");
    1054         query.setString("name", name);
     1055        org.hibernate.query.Query<DirectoryData> query = HibernateUtil.getPredefinedQuery(session,
     1056          "GET_SUBDIRECTORY_WITH_NAME", DirectoryData.class);
     1057        query.setParameter("name", name, TypeWrapper.H_STRING);
    10551058        query.setEntity("parent", parent);
    1056         directory = HibernateUtil.loadData(DirectoryData.class, query);
     1059        directory = HibernateUtil.loadData(query);
    10571060      }
    10581061     
     
    11021105        org.hibernate.query.Query<MimeTypeData> query = HibernateUtil.getPredefinedQuery(session,
    11031106          "GET_MIME_TYPE_FROM_EXTENSION", MimeTypeData.class);
    1104         query.setString("extension", extension);
     1107        query.setParameter("extension", extension, TypeWrapper.H_STRING);
    11051108        mimeType = HibernateUtil.loadData(query);
    11061109      }
     
    11561159      if (quotaType == null && systemId == null)
    11571160      {
    1158         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_TYPE_WITH_NAME");
    1159         query.setString("name", name);
    1160         quotaType = HibernateUtil.loadData(QuotaTypeData.class, query);
     1161        org.hibernate.query.Query<QuotaTypeData> query = HibernateUtil.getPredefinedQuery(session,
     1162          "GET_QUOTA_TYPE_WITH_NAME", QuotaTypeData.class);
     1163        query.setParameter("name", name, TypeWrapper.H_STRING);
     1164        quotaType = HibernateUtil.loadData(query);
    11611165      }
    11621166     
     
    12081212      if (quota == null && systemId == null)
    12091213      {
    1210         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_WITH_NAME");
    1211         query.setString("name", name);
    1212         quota = HibernateUtil.loadData(QuotaData.class, query);
     1214        org.hibernate.query.Query<QuotaData> query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_WITH_NAME", QuotaData.class);
     1215        query.setParameter("name", name, TypeWrapper.H_STRING);
     1216        quota = HibernateUtil.loadData(query);
    12131217      }
    12141218     
     
    12631267      if (user == null && systemId == null)
    12641268      {
    1265         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN");
    1266         query.setString("login", login);
    1267         user = HibernateUtil.loadData(UserData.class, query);
     1269        org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN", UserData.class);
     1270        query.setParameter("login", login, TypeWrapper.H_STRING);
     1271        user = HibernateUtil.loadData(query);
    12681272      }
    12691273     
     
    13261330      if (group == null && systemId == null)
    13271331      {
    1328         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_WITH_NAME");
    1329         query.setString("name", name);
    1330         group = HibernateUtil.loadData(GroupData.class, query);
     1332        org.hibernate.query.Query<GroupData> query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_WITH_NAME", GroupData.class);
     1333        query.setParameter("name", name, TypeWrapper.H_STRING);
     1334        group = HibernateUtil.loadData(query);
    13311335      }
    13321336     
     
    13781382      if (role == null && systemId == null)
    13791383      {
    1380         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ROLE_WITH_NAME");
    1381         query.setString("name", name);
    1382         role = HibernateUtil.loadData(RoleData.class, query);
     1384        org.hibernate.query.Query<RoleData> query = HibernateUtil.getPredefinedQuery(session, "GET_ROLE_WITH_NAME", RoleData.class);
     1385        query.setParameter("name", name, TypeWrapper.H_STRING);
     1386        role = HibernateUtil.loadData(query);
    13831387      }
    13841388
     
    15171521      if (u == null)
    15181522      {
    1519         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    1520             "GET_UNIT_WITH_NAME_FOR_QUANTITY");
    1521         query.setString("name", name);
     1523        org.hibernate.query.Query<UnitData> query = HibernateUtil.getPredefinedQuery(session,
     1524            "GET_UNIT_WITH_NAME_FOR_QUANTITY", UnitData.class);
     1525        query.setParameter("name", name, TypeWrapper.H_STRING);
    15221526        query.setEntity("quantity", quantity);
    1523         u = HibernateUtil.loadData(UnitData.class, query);
     1527        u = HibernateUtil.loadData(query);
    15241528      }
    15251529     
     
    16001604      if (sw == null)
    16011605      {
    1602         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SOFTWARE_WITH_NAME");
    1603         query.setString("name", name);
    1604         sw = HibernateUtil.loadData(SoftwareData.class, query);
     1606        org.hibernate.query.Query<SoftwareData> query = HibernateUtil.getPredefinedQuery(session, "GET_SOFTWARE_WITH_NAME", SoftwareData.class);
     1607        query.setParameter("name", name, TypeWrapper.H_STRING);
     1608        sw = HibernateUtil.loadData(query);
    16051609      }
    16061610     
     
    16481652      if (hw == null)
    16491653      {
    1650         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_HARDWARE_WITH_NAME");
    1651         query.setString("name", name);
    1652         hw = HibernateUtil.loadData(HardwareData.class, query);
     1654        org.hibernate.query.Query<HardwareData> query = HibernateUtil.getPredefinedQuery(session, "GET_HARDWARE_WITH_NAME", HardwareData.class);
     1655        query.setParameter("name", name, TypeWrapper.H_STRING);
     1656        hw = HibernateUtil.loadData(query);
    16531657      }
    16541658     
     
    17001704      if (subtype == null)
    17011705      {
    1702         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE");
    1703         query.setString("name", name);
    1704         query.setInteger("itemType", itemType.getValue());
    1705         subtype = HibernateUtil.loadData(ItemSubtypeData.class, query);
     1706        org.hibernate.query.Query<ItemSubtypeData> query = HibernateUtil.getPredefinedQuery(session,
     1707          "GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE", ItemSubtypeData.class);
     1708        query.setParameter("name", name, TypeWrapper.H_STRING);
     1709        query.setParameter("itemType", itemType.getValue(), TypeWrapper.H_INTEGER);
     1710        subtype = HibernateUtil.loadData(query);
    17061711       
    17071712        if (subtype != null && subtype.getSystemId() == null)
     
    17791784      if (pt == null)
    17801785      {
    1781         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_BIOPLATETYPE_WITH_NAME");
    1782         query.setString("name", name);
    1783         pt = HibernateUtil.loadData(BioPlateTypeData.class, query);
     1786        org.hibernate.query.Query<BioPlateTypeData> query = HibernateUtil.getPredefinedQuery(session, "GET_BIOPLATETYPE_WITH_NAME", BioPlateTypeData.class);
     1787        query.setParameter("name", name, TypeWrapper.H_STRING);
     1788        pt = HibernateUtil.loadData(query);
    17841789      }
    17851790 
     
    18741879      if (pg == null)
    18751880      {
    1876         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLATE_GEOMETRY_WITH_SIZE");
    1877         query.setInteger("rows", rows);
    1878         query.setInteger("columns", columns);
    1879         pg = HibernateUtil.loadData(PlateGeometryData.class, query);
     1881        org.hibernate.query.Query<PlateGeometryData> query = HibernateUtil.getPredefinedQuery(session,
     1882          "GET_PLATE_GEOMETRY_WITH_SIZE", PlateGeometryData.class);
     1883        query.setParameter("rows", rows, TypeWrapper.H_INTEGER);
     1884        query.setParameter("columns", columns, TypeWrapper.H_INTEGER);
     1885        pg = HibernateUtil.loadData(query);
    18801886      }
    18811887
     
    19351941      if (pm == null)
    19361942      {
    1937         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLATE_MAPPING_WITH_PROPERTIES");
    1938         query.setInteger("sourceCount", sourceCount);
     1943        org.hibernate.query.Query<PlateMappingData> query = HibernateUtil.getPredefinedQuery(session,
     1944          "GET_PLATE_MAPPING_WITH_PROPERTIES", PlateMappingData.class);
     1945        query.setParameter("sourceCount", sourceCount, TypeWrapper.H_INTEGER);
    19391946        query.setEntity("sourceGeometry", source);
    1940         query.setInteger("destinationCount", destinationCount);
     1947        query.setParameter("destinationCount", destinationCount, TypeWrapper.H_INTEGER);
    19411948        query.setEntity("destinationGeometry", destination);
    19421949        pm = HibernateUtil.loadData(PlateMappingData.class, query);
     
    20382045      if (tag == null)
    20392046      {
    2040         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_TAG_WITH_NAME");
    2041         query.setString("name", name);
    2042         tag = HibernateUtil.loadData(TagData.class, query);
     2047        org.hibernate.query.Query<TagData> query = HibernateUtil.getPredefinedQuery(session, "GET_TAG_WITH_NAME", TagData.class);
     2048        query.setParameter("name", name, TypeWrapper.H_STRING);
     2049        tag = HibernateUtil.loadData(query);
    20432050      }
    20442051     
     
    20872094      if (at == null)
    20882095      {
    2089         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ANNOTATION_TYPE_WITH_NAME");
    2090         query.setString("name", name);
    2091         at = HibernateUtil.loadData(AnnotationTypeData.class, query);
     2096        org.hibernate.query.Query<AnnotationTypeData> query = HibernateUtil.getPredefinedQuery(session, "GET_ANNOTATION_TYPE_WITH_NAME", AnnotationTypeData.class);
     2097        query.setParameter("name", name, TypeWrapper.H_STRING);
     2098        at = HibernateUtil.loadData(query);
    20922099      }
    20932100     
     
    22752282      if (client == null)
    22762283      {
    2277         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_CLIENT_FOR_EXTERNAL_ID");
    2278         query.setString("externalId", externalId);
    2279         client = HibernateUtil.loadData(ClientData.class, query);
     2284        org.hibernate.query.Query<ClientData> query = HibernateUtil.getPredefinedQuery(session, "GET_CLIENT_FOR_EXTERNAL_ID", ClientData.class);
     2285        query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     2286        client = HibernateUtil.loadData(query);
    22802287      }
    22812288     
     
    23252332      if (news == null)
    23262333      {
    2327         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_NEWS_WITH_NAME");
    2328         query.setString("name", name);
    2329         news = HibernateUtil.loadData(NewsData.class, query);
     2334        org.hibernate.query.Query<NewsData> query = HibernateUtil.getPredefinedQuery(session, "GET_NEWS_WITH_NAME", NewsData.class);
     2335        query.setParameter("name", name, TypeWrapper.H_STRING);
     2336        news = HibernateUtil.loadData(query);
    23302337      }
    23312338      if (news != null)
     
    23702377      if (pluginType == null)
    23712378      {
    2372         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PLUGINTYPE_FOR_INTERFACENAME");
    2373         query.setString("interfaceName", interfaceName);
    2374         pluginType = HibernateUtil.loadData(PluginTypeData.class, query);
     2379        org.hibernate.query.Query<PluginTypeData> query = HibernateUtil.getPredefinedQuery(session, "GET_PLUGINTYPE_FOR_INTERFACENAME", PluginTypeData.class);
     2380        query.setParameter("interfaceName", interfaceName, TypeWrapper.H_STRING);
     2381        pluginType = HibernateUtil.loadData(query);
    23752382      }
    23762383     
     
    25002507      dc = sessionControl.newDbControl();
    25012508     
    2502       org.hibernate.query.Query query = null;
     2509      org.hibernate.query.Query<PluginConfigurationData> query = null;
    25032510      if (update)
    25042511      {
     
    25062513        // given name already exists
    25072514        query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
    2508           "GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME");
     2515          "GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME", PluginConfigurationData.class);
    25092516        /*
    25102517          SELECT pc
     
    25262533        {
    25272534          // Check if it already exists
    2528           query.setString("className", pluginClassName);
    2529           query.setString("name", name);
    2530           PluginConfigurationData config = HibernateUtil.loadData(PluginConfigurationData.class, query);
     2535          query.setParameter("className", pluginClassName, TypeWrapper.H_STRING);
     2536          query.setParameter("name", name, TypeWrapper.H_STRING);
     2537          PluginConfigurationData config = HibernateUtil.loadData(query);
    25312538         
    25322539          if (config != null)
     
    25882595      if (formula == null)
    25892596      {
    2590         org.hibernate.query.Query query = null;
     2597        org.hibernate.query.Query<FormulaData> query = null;
    25912598        if (rawDataType == null)
    25922599        {
    2593           query = HibernateUtil.getPredefinedQuery(session, "GET_FORMULA_WITH_NAME_AND_CHANNELS");     
    2594           query.setInteger("channels", channels);
     2600          query = HibernateUtil.getPredefinedQuery(session, "GET_FORMULA_WITH_NAME_AND_CHANNELS", FormulaData.class);     
     2601          query.setParameter("channels", channels, TypeWrapper.H_INTEGER);
    25952602        }
    25962603        else
    25972604        {
    2598           query = HibernateUtil.getPredefinedQuery(session, "GET_FORMULA_WITH_NAME_AND_TYPE");
    2599           query.setString("rawDataType", rawDataType);
    2600         }
    2601         query.setString("name", name);
    2602         formula = HibernateUtil.loadData(FormulaData.class, query);
     2605          query = HibernateUtil.getPredefinedQuery(session, "GET_FORMULA_WITH_NAME_AND_TYPE", FormulaData.class);
     2606          query.setParameter("rawDataType", rawDataType, TypeWrapper.H_STRING);
     2607        }
     2608        query.setParameter("name", name, TypeWrapper.H_STRING);
     2609        formula = HibernateUtil.loadData(query);
    26032610      }
    26042611      if (formula != null)
     
    26552662      if (platform == null)
    26562663      {
    2657         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    2658           "GET_PLATFORM_FOR_EXTERNAL_ID");
    2659         query.setString("externalId", externalId);
    2660         platform = HibernateUtil.loadData(PlatformData.class, query);
     2664        org.hibernate.query.Query<PlatformData> query = HibernateUtil.getPredefinedQuery(session,
     2665          "GET_PLATFORM_FOR_EXTERNAL_ID", PlatformData.class);
     2666        query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     2667        platform = HibernateUtil.loadData(query);
    26612668      }
    26622669     
     
    27392746      if (variant == null)
    27402747      {
    2741         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    2742           "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID");
    2743         query.setString("externalId", externalId);
    2744         variant = HibernateUtil.loadData(PlatformVariantData.class, query);
     2748        org.hibernate.query.Query<PlatformVariantData> query = HibernateUtil.getPredefinedQuery(session,
     2749          "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID", PlatformVariantData.class);
     2750        query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     2751        variant = HibernateUtil.loadData(query);
    27452752      }
    27462753     
     
    28292836      if (fileType == null)
    28302837      {
    2831         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    2832           "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
    2833         query.setString("externalId", externalId);
    2834         fileType = HibernateUtil.loadData(DataFileTypeData.class, query);
     2838        org.hibernate.query.Query<DataFileTypeData> query = HibernateUtil.getPredefinedQuery(session,
     2839          "GET_DATAFILETYPE_FOR_EXTERNAL_ID", DataFileTypeData.class);
     2840        query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     2841        fileType = HibernateUtil.loadData(query);
    28352842      }
    28362843     
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/InternalJobQueue.java

    r7372 r7374  
    3030import net.sf.basedb.core.data.ShareableData;
    3131import net.sf.basedb.core.data.UserData;
     32import net.sf.basedb.core.hibernate.TypeWrapper;
    3233import net.sf.basedb.core.data.ItemKeyData;
    3334import net.sf.basedb.core.data.ProjectKeyData;
     
    322323        "FIND_JOBS_IN_QUEUE" : "FIND_INTERNAL_JOBS_IN_QUEUE";
    323324     
    324       org.hibernate.query.Query query =
    325         HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), hqlName);
     325      org.hibernate.query.Query<JobData> query =
     326        HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), hqlName, JobData.class);
    326327      /*
    327328        SELECT job
     
    334335        ORDER BY job.priority ASC, job.scheduled ASC
    335336      */
    336       query.setInteger("status", Job.Status.WAITING.getValue());
    337       query.setInteger("type", Job.Type.RUN_PLUGIN.getValue());
     337      query.setParameter("status", Job.Status.WAITING.getValue(), TypeWrapper.H_INTEGER);
     338      query.setParameter("type", Job.Type.RUN_PLUGIN.getValue(), TypeWrapper.H_INTEGER);
    338339      List<JobData> jobs = HibernateUtil.loadList(JobData.class, query, null);
    339340     
     
    398399      dc = sc.newDbControl();
    399400     
    400       org.hibernate.query.Query query =
    401         HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "FIND_EXTERNAL_JOBS_FOR_STATUS_UPDATE");
     401      org.hibernate.query.Query<JobData> query =
     402        HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "FIND_EXTERNAL_JOBS_FOR_STATUS_UPDATE", JobData.class);
    402403      /*
    403404        SELECT job
     
    407408        AND NOT job.signalTransporter IS NULL
    408409      */
    409       query.setInteger("type", Job.Type.OTHER.getValue());
     410      query.setParameter("type", Job.Type.OTHER.getValue(), TypeWrapper.H_INTEGER);
    410411      List<JobData> jobs = HibernateUtil.loadList(JobData.class, query, null);
    411412     
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ItemKey.java

    r7372 r7374  
    196196        WHERE ik.id NOT IN (:used)
    197197      */
    198       query.setParameterList("used", used, TypeWrapper.INTEGER.getHibernateType());
     198      query.setParameterList("used", used, TypeWrapper.H_INTEGER);
    199199      List<ItemKeyData> unused = HibernateUtil.loadList(ItemKeyData.class, query, null);
    200200      for (ItemKeyData ik : unused)
     
    403403      //    user/permissions combinations
    404404      int numPermissions = userPermissions == null ? 0 : userPermissions.size();
    405       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ITEMKEY_IDS_FOR_USERCOUNT");
     405      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session,
     406        "GET_ITEMKEY_IDS_FOR_USERCOUNT", Integer.class);
    406407      /*
    407408        SELECT ik.id FROM ItemKeyData ik
     
    410411        HAVING COUNT(u.index) = :numPermissions
    411412      */
    412       query.setInteger("numPermissions", numPermissions);
    413       List<Integer> candidates = HibernateUtil.loadList(Integer.class, query, null);
     413      query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     414      List<Integer> candidates = HibernateUtil.loadList(query, null);
    414415      if (candidates.size() > 0 && numPermissions > 0 && userPermissions != null)
    415416      {
     
    429430          "WHERE uk.keyId IN (:candidates) AND ("+sb.toString()+") "+
    430431          "GROUP BY uk.keyId "+
    431           "HAVING COUNT(uk.userId) = :numPermissions"
     432          "HAVING COUNT(uk.userId) = :numPermissions", Integer.class
    432433        );
    433         query.setParameterList("candidates", candidates, TypeWrapper.INTEGER.getHibernateType());
    434         query.setInteger("numPermissions", numPermissions);
    435         candidates = HibernateUtil.loadList(Integer.class, query, null);
     434        query.setParameterList("candidates", candidates, TypeWrapper.H_INTEGER);
     435        query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     436        candidates = HibernateUtil.loadList(query, null);
    436437      }
    437438     
     
    441442        //    group/permissions combinations
    442443        numPermissions = groupPermissions == null ? 0 : groupPermissions.size();
    443         query = HibernateUtil.getPredefinedQuery(session, "GET_ITEMKEY_IDS_FOR_GROUPCOUNT");
     444        query = HibernateUtil.getPredefinedQuery(session, "GET_ITEMKEY_IDS_FOR_GROUPCOUNT", Integer.class);
    444445        /*
    445446          SELECT ik.id FROM ItemKeyData ik
     
    449450          HAVING COUNT(g.index) = :numPermissions
    450451        */
    451         query.setInteger("numPermissions", numPermissions);
    452         query.setParameterList("candidates", candidates, TypeWrapper.INTEGER.getHibernateType());
    453         candidates = HibernateUtil.loadList(Integer.class, query, null);       
     452        query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     453        query.setParameterList("candidates", candidates, TypeWrapper.H_INTEGER);
     454        candidates = HibernateUtil.loadList(query, null);       
    454455      }
    455456
     
    472473          "WHERE gk.keyId IN (:candidates) AND ("+sb.toString()+") "+
    473474          "GROUP BY gk.keyId "+
    474           "HAVING COUNT(gk.groupId) = :numPermissions"
     475          "HAVING COUNT(gk.groupId) = :numPermissions", Integer.class
    475476        );
    476         query.setParameterList("candidates", candidates, TypeWrapper.INTEGER.getHibernateType());
    477         query.setInteger("numPermissions", numPermissions);
    478         candidates = HibernateUtil.loadList(Integer.class, query, null);
     477        query.setParameterList("candidates", candidates, TypeWrapper.H_INTEGER);
     478        query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     479        candidates = HibernateUtil.loadList(query, null);
    479480      }
    480481 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Job.java

    r7373 r7374  
    3333import net.sf.basedb.core.data.ShareableData;
    3434import net.sf.basedb.core.data.UserData;
     35import net.sf.basedb.core.hibernate.TypeWrapper;
    3536import net.sf.basedb.core.plugin.ParameterValues;
    3637import net.sf.basedb.core.plugin.Plugin;
     
    20022003    private void updateProgress(org.hibernate.Session session, int percent, String statusMessage)
    20032004    {
    2004       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "UPDATE_JOB_STATUS");
    2005       query.setInteger("percent", percent);
    2006       query.setString("statusMessage", statusMessage);
    2007       query.setInteger("id", jobId);
     2005      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session, "UPDATE_JOB_STATUS");
     2006      query.setParameter("percent", percent, TypeWrapper.H_INTEGER);
     2007      query.setParameter("statusMessage", statusMessage, TypeWrapper.H_STRING);
     2008      query.setParameter("id", jobId, TypeWrapper.H_INTEGER);
    20082009      HibernateUtil.executeUpdate(query);
    20092010    }
     
    20112012    private void appendProgress(org.hibernate.Session session, String statusMessage)
    20122013    {
    2013       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "APPEND_JOB_STATUS");
    2014       query.setString("statusMessage", statusMessage);
    2015       query.setInteger("id", jobId);
     2014      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session, "APPEND_JOB_STATUS");
     2015      query.setParameter("statusMessage", statusMessage, TypeWrapper.H_STRING);
     2016      query.setParameter("id", jobId, TypeWrapper.H_INTEGER);
    20162017      HibernateUtil.executeUpdate(query);
    20172018    }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/JobAgent.java

    r7373 r7374  
    2929
    3030import net.sf.basedb.core.data.JobAgentData;
     31import net.sf.basedb.core.hibernate.TypeWrapper;
    3132import net.sf.basedb.core.query.Expressions;
    3233import net.sf.basedb.core.query.Hql;
     
    141142      WHERE jag.externalId = :externalId
    142143    */
    143     query.setString("externalId", externalId);
     144    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    144145    JobAgent jag = dc.getItem(JobAgent.class, HibernateUtil.loadData(query));
    145146    if (jag == null) throw new ItemNotFoundException("JobAgent[externalId="+externalId+"]");
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Keyring.java

    r7373 r7374  
    323323    {
    324324      // Get the groups where the user is a direct member
    325       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ROLE_IDS_FOR_USER");
     325      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_ROLE_IDS_FOR_USER", Integer.class);
    326326      /*
    327327        SELECT ur.roleId
     
    329329        WHERE ur.userId = :userId
    330330      */
    331       query.setInteger("userId", userId);
    332       temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     331      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
     332      temp = new HashSet<Integer>(HibernateUtil.loadList(query, null));
    333333      roles = Collections.unmodifiableSet(temp);
    334334    }
     
    350350    {
    351351      // Get the groups where the user is a direct member
    352       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_IDS_FOR_USER");
     352      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_IDS_FOR_USER", Integer.class);
    353353      /*
    354354        SELECT ug.groupId
     
    356356        WHERE ug.userId = :userId
    357357      */
    358       query.setInteger("userId", userId);
    359       temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     358      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
     359      temp = new HashSet<Integer>(HibernateUtil.loadList(query, null));
    360360     
    361       query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_GROUP_ID_FOR_USER");
     361      query = HibernateUtil.getPredefinedQuery(session, "GET_QUOTA_GROUP_ID_FOR_USER", Integer.class);
    362362      /*
    363363        SELECT usr.quotaGroup.id
     
    365365        WHERE usr.id = :userId
    366366      */
    367       query.setInteger("userId", userId);
    368       Integer quotaGroupId = HibernateUtil.loadData(Integer.class, query);
     367      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
     368      Integer quotaGroupId = HibernateUtil.loadData(query);
    369369      if (quotaGroupId != null) temp.add(quotaGroupId);
    370370
     
    372372      if (temp.size() > 0)
    373373      {
    374         query = HibernateUtil.getPredefinedQuery(session, "GET_PARENTGROUPS_IDS_FOR_GROUPS");
     374        query = HibernateUtil.getPredefinedQuery(session, "GET_PARENTGROUPS_IDS_FOR_GROUPS", Integer.class);
    375375        /*
    376376          SELECT DISTINCT gg.parentId
     
    381381        do
    382382        {
    383           query.setParameterList("groups", temp, TypeWrapper.INTEGER.getHibernateType());
    384         } while (temp.addAll(HibernateUtil.loadList(Integer.class, query, null)));
     383          query.setParameterList("groups", temp, TypeWrapper.H_INTEGER);
     384        } while (temp.addAll(HibernateUtil.loadList(query, null)));
    385385        // repeat until no more new groups are found
    386386      }
     
    390390     
    391391      // Load the subset of groups that has hiddenMembers = false
    392       query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPS_WITH_NONHIDDENMEMBERS");
     392      query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPS_WITH_NONHIDDENMEMBERS", Integer.class);
    393393      /*
    394394        SELECT grp.id
     
    397397        AND grp.id IN (:groups)
    398398      */
    399       query.setParameterList("groups", groups, TypeWrapper.INTEGER.getHibernateType());
    400       temp = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, null));
     399      query.setParameterList("groups", groups, TypeWrapper.H_INTEGER);
     400      temp = new HashSet<Integer>(HibernateUtil.loadList(query, null));
    401401      groupsWithNonHiddenMembers = Collections.unmodifiableSet(temp);
    402402    }
     
    424424        WHERE p.owner = :userId
    425425      */
    426       query.setInteger("userId", userId);
     426      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
    427427      for (Integer i : HibernateUtil.loadList(query, null))
    428428      {
     
    437437        WHERE up.userId = :userId
    438438      */
    439       query2.setInteger("userId", userId);
     439      query2.setParameter("userId", userId, TypeWrapper.H_INTEGER);
    440440      for (UserProjects up : HibernateUtil.loadList(query2, null))
    441441      {
     
    453453          WHERE gp.groupId IN (:groups)
    454454        */
    455         query3.setParameterList("groups", groups, TypeWrapper.INTEGER.getHibernateType());
     455        query3.setParameterList("groups", groups, TypeWrapper.H_INTEGER);
    456456        for (GroupProjects gp : HibernateUtil.loadList(query3, null))
    457457        {
     
    493493       
    494494        // Get direct members of the active project
    495         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_PROJECT");
     495        org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_IDS_FOR_PROJECT", Integer.class);
    496496        /*
    497497          SELECT up.userId
     
    499499          WHERE up.projectId = :projectId
    500500        */
    501         query.setInteger("projectId", projectId);
    502         temp.addAll(HibernateUtil.loadList(Integer.class, query, null));
     501        query.setParameter("projectId", projectId, TypeWrapper.H_INTEGER);
     502        temp.addAll(HibernateUtil.loadList(query, null));
    503503       
    504504        // Get groups that are direct members of the active project
    505         query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_IDS_FOR_PROJECT");
     505        query = HibernateUtil.getPredefinedQuery(session, "GET_GROUP_IDS_FOR_PROJECT", Integer.class);
    506506        /*
    507507          SELECT gp.groupId
     
    509509          WHERE gp.projectId = :projectId
    510510        */
    511         query.setInteger("projectId", projectId);
     511        query.setParameter("projectId", projectId, TypeWrapper.H_INTEGER);
    512512        // Load the direct groups and subgroups
    513         Set<Integer> projectGroups = Group.getGroupsRecursive(session, HibernateUtil.loadList(Integer.class, query, null));
     513        Set<Integer> projectGroups = Group.getGroupsRecursive(session, HibernateUtil.loadList(query, null));
    514514       
    515515        if (projectGroups.size() > 0)
    516516        {
    517517          // Finally, filter away groups that has hiddenMembers=true
    518           query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPS_WITH_NONHIDDENMEMBERS");
     518          query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPS_WITH_NONHIDDENMEMBERS", Integer.class);
    519519          /*
    520520            SELECT grp.id
     
    523523            AND grp.id IN (:groups)
    524524          */
    525           query.setParameterList("groups", projectGroups, TypeWrapper.INTEGER.getHibernateType());
    526           projectGroups.retainAll(HibernateUtil.loadList(Integer.class, query, null));
     525          query.setParameterList("groups", projectGroups, TypeWrapper.H_INTEGER);
     526          projectGroups.retainAll(HibernateUtil.loadList(query, null));
    527527        }
    528528       
     
    549549    {
    550550      // Load keys shared directly to the logged in user
    551       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USERKEYS_FOR_USER");
     551      org.hibernate.query.Query<KeyPermission> query = HibernateUtil.getPredefinedQuery(session,
     552        "GET_USERKEYS_FOR_USER", KeyPermission.class);
    552553      /*
    553554        SELECT uk
     
    555556        WHERE uk.userId = :userId
    556557      */
    557       query.setInteger("userId", userId);
    558       List<KeyPermission> keys = HibernateUtil.loadList(KeyPermission.class, query, null);
     558      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
     559      List<KeyPermission> keys = HibernateUtil.loadList(query, null);
    559560
    560561      // Load keys shared to any of the groups where the user is a member
    561562      if (groups.size() > 0)
    562563      {
    563         query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPKEYS_FOR_GROUPS");
     564        query = HibernateUtil.getPredefinedQuery(session, "GET_GROUPKEYS_FOR_GROUPS", KeyPermission.class);
    564565        /*
    565566          SELECT gk
     
    567568          WHERE gk.groupId IN (:groups)
    568569        */
    569         query.setParameterList("groups", groups, TypeWrapper.INTEGER.getHibernateType());
    570         keys.addAll(HibernateUtil.loadList(KeyPermission.class, query, null));
     570        query.setParameterList("groups", groups, TypeWrapper.H_INTEGER);
     571        keys.addAll(HibernateUtil.loadList(query, null));
    571572      }
    572573
     
    619620    {
    620621      // Load the role keys from the database
    621       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_ROLEKEYS_FOR_USER");
     622      org.hibernate.query.Query<RoleKeys> query = HibernateUtil.getPredefinedQuery(session, "GET_ROLEKEYS_FOR_USER", RoleKeys.class);
    622623      /*
    623624        SELECT rk
     
    626627        ORDER BY rk.keyId
    627628      */
    628       query.setInteger("userId", userId);
    629       List<RoleKeys> roleKeys = HibernateUtil.loadList(RoleKeys.class, query, null);
     629      query.setParameter("userId", userId, TypeWrapper.H_INTEGER);
     630      List<RoleKeys> roleKeys = HibernateUtil.loadList(query, null);
    630631     
    631632      // Copy the permission from the list to the array
     
    676677    {
    677678      // Load the pluginpermisson keys for the active plugin
    678       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_KEYS_FOR_PLUGIN");
     679      org.hibernate.query.Query<PluginKeys> query = HibernateUtil.getPredefinedQuery(session, "GET_KEYS_FOR_PLUGIN", PluginKeys.class);
    679680      /*
    680681          SELECT pdk
     
    683684        ORDER BY pdk.roleKeyId             
    684685      */
    685       query.setInteger("pluginId", pluginId);
    686       List<PluginKeys> keys = HibernateUtil.loadList(PluginKeys.class, query, null);
     686      query.setParameter("pluginId", pluginId, TypeWrapper.H_INTEGER);
     687      List<PluginKeys> keys = HibernateUtil.loadList(query, null);
    687688     
    688689      // Copy the permissions from the list to the array
     
    712713    {
    713714      // Load the project keys for the active project
    714       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEYS_FOR_PROJECT");
     715      org.hibernate.query.Query<ProjectKeys> query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEYS_FOR_PROJECT", ProjectKeys.class);
    715716      /*
    716717        SELECT pk
     
    719720        ORDER BY pk.keyId
    720721      */
    721       query.setInteger("projectId", projectId);
    722       List<ProjectKeys> keys = HibernateUtil.loadList(ProjectKeys.class, query, null);
     722      query.setParameter("projectId", projectId, TypeWrapper.H_INTEGER);
     723      List<ProjectKeys> keys = HibernateUtil.loadList(query, null);
    723724
    724725      // Copy the permissions from the List to the array
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/LogControl.java

    r7372 r7374  
    138138    @return A Query
    139139  */
    140   public org.hibernate.query.Query createHqlQuery(String hql)
     140  public org.hibernate.query.Query<?> createHqlQuery(String hql)
    141141  {
    142142    return HibernateUtil.createQuery(getSession(), hql);
    143143  }
    144144 
     145  /**
     146    Creates a Hibernate HQL query with a known return type. Use this to get information
     147    from the database that is relevent for the logging implementation.
     148    The query uses the stateless session, which means that there
     149    is no first- or second-level cache and on support for initialization
     150    of proxies. We recommend that queries are used to return
     151    scalar values only, not entities.
     152    @return A Query
     153    @since 3.12
     154  */
     155  public <R> org.hibernate.query.Query<R> createHqlQuery(String hql, Class<R> returnType)
     156  {
     157    return HibernateUtil.createQuery(getSession(), hql, returnType);
     158  }
     159
    145160  /**
    146161    Flushes any batched changes to the database.
     
    170185    @return A query
    171186  */
    172   public org.hibernate.query.Query createSqlQuery(String sql)
     187  public org.hibernate.query.Query<?> createSqlQuery(String sql)
    173188  {
    174189    return HibernateUtil.createSqlQuery(getSession(), sql);
     190  }
     191 
     192  /**
     193    Creates a Hibernate SQL query with a known return type. Use this to get information
     194    from the database that is relevent for the logging
     195    implementation. The query uses the stateless session.
     196    @return A query
     197    @since 3.12
     198  */
     199  public <R> org.hibernate.query.Query<R> createSqlQuery(String sql, Class<R> returnType)
     200  {
     201    return HibernateUtil.createSqlQuery(getSession(), sql, returnType);
    175202  }
    176203 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/MeasuredBioMaterial.java

    r7373 r7374  
    3737import net.sf.basedb.core.data.BioWellData;
    3838import net.sf.basedb.core.data.MeasuredBioMaterialData;
     39import net.sf.basedb.core.hibernate.TypeWrapper;
    3940import net.sf.basedb.core.log.ChangeType;
    4041import net.sf.basedb.core.log.LoggingInterceptor;
     
    637638    {
    638639      // Load current value from the database
    639       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "GET_REMAINING_QUANTITY");
     640      org.hibernate.query.Query<Float> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     641        "GET_REMAINING_QUANTITY", Float.class);
    640642      query.setEntity("bioMaterial", bioMaterial);
    641       Float remainBefore = HibernateUtil.loadData(Float.class, query);
     643      Float remainBefore = HibernateUtil.loadData(query);
    642644     
    643645      // Make the change in the database
    644       query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "UPDATE_REMAINING_QUANTITY");
     646      org.hibernate.query.Query<?> update = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(), "UPDATE_REMAINING_QUANTITY");
    645647      /*
    646648        UPDATE MeasuredBioMaterialData mbm
     
    648650        WHERE mbm = :bioMaterial
    649651      */
    650       query.setFloat("used", usedQuantity);
    651       query.setEntity("bioMaterial", bioMaterial);
    652       HibernateUtil.executeUpdate(query);
     652      update.setParameter("used", usedQuantity, TypeWrapper.H_FLOAT);
     653      update.setEntity("bioMaterial", bioMaterial);
     654      HibernateUtil.executeUpdate(update);
    653655
    654656      // Notify the logging system
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Message.java

    r7373 r7374  
    2525import net.sf.basedb.core.data.MessageData;
    2626import net.sf.basedb.core.data.UserData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728import net.sf.basedb.core.query.Restrictions;
    2829import net.sf.basedb.core.query.Hql;
     
    148149      WHERE msg.to = :user AND msg.read = false AND msg.removedBy IS NULL
    149150    */
    150     query.setInteger("user", user == null ? dc.getSessionControl().getLoggedInUserId() : user.getId());
     151    query.setParameter("user", user == null ? dc.getSessionControl().getLoggedInUserId() : user.getId(), TypeWrapper.H_INTEGER);
    151152    query.setCacheable(cacheResult);
    152153    return HibernateUtil.loadData(query);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/MimeType.java

    r7373 r7374  
    2626
    2727import net.sf.basedb.core.data.MimeTypeData;
     28import net.sf.basedb.core.hibernate.TypeWrapper;
    2829/**
    2930  This class is used to represent mime types. The mime types are important
     
    115116      WHERE mt.extension = :extension
    116117    */
    117     query.setString("extension", extension);
     118    query.setParameter("extension", extension, TypeWrapper.H_STRING);
    118119    MimeType mt = dc.getItem(MimeType.class, HibernateUtil.loadData(query));
    119120    if (mt == null) throw new ItemNotFoundException("MimeType[extension="+extension+"]");
     
    151152    String extension = dot >= 0 ? name.substring(dot + 1) : name;
    152153    org.hibernate.Session session = dc.getHibernateSession();
    153     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_MIME_TYPE_FROM_EXTENSION");
     154    org.hibernate.query.Query<MimeTypeData> query = HibernateUtil.getPredefinedQuery(session,
     155      "GET_MIME_TYPE_FROM_EXTENSION", MimeTypeData.class);
    154156    /*
    155157      SELECT mt
     
    157159      WHERE mt.extension = :extension
    158160    */
    159     query.setString("extension", extension);
    160     MimeTypeData mt = HibernateUtil.loadData(MimeTypeData.class, query);
     161    query.setParameter("extension", extension, TypeWrapper.H_STRING);
     162    MimeTypeData mt = HibernateUtil.loadData(query);
    161163    if (mt != null) mimeType = mt.getName();
    162164    return mimeType;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Platform.java

    r7373 r7374  
    2828import net.sf.basedb.core.data.PlatformData;
    2929import net.sf.basedb.core.data.PlatformFileTypeData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3031import net.sf.basedb.core.query.Hql;
    3132import net.sf.basedb.core.query.Restrictions;
     
    168169      WHERE plf.externalId = :externalId
    169170    */
    170     query.setString("externalId", externalId);
     171    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    171172    Platform p = dc.getItem(Platform.class, HibernateUtil.loadData(query));
    172173    if (p == null) throw new ItemNotFoundException("Platform[externalId="+externalId+"]");
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/PlatformVariant.java

    r7373 r7374  
    2626import net.sf.basedb.core.Transactional.Action;
    2727import net.sf.basedb.core.data.PlatformVariantData;
     28import net.sf.basedb.core.hibernate.TypeWrapper;
    2829
    2930/**
     
    170171      WHERE plv.externalId = :externalId
    171172    */
    172     query.setString("externalId", externalId);
     173    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
    173174    PlatformVariant v = dc.getItem(PlatformVariant.class, HibernateUtil.loadData(query));
    174175    if (v == null) throw new ItemNotFoundException("PlatformVariant[externalId="+externalId+"]");
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/PluginDefinition.java

    r7373 r7374  
    195195      WHERE pd.className = :className
    196196    */
    197     query.setString("className", className);
     197    query.setParameter("className", className, TypeWrapper.H_STRING);
    198198    PluginDefinition pd = dc.getItem(PluginDefinition.class, HibernateUtil.loadData(query));
    199199    if (pd == null) throw new ItemNotFoundException("PluginDefinition[className="+className+"]");
     
    282282   
    283283    org.hibernate.Session session = dc.getHibernateSession();
    284     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT");
     284    org.hibernate.query.Query<Object[]> query = HibernateUtil.getPredefinedQuery(session,
     285      "COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT", Object[].class);
    285286    /*
    286287      SELECT plg.mainType, count(DISTINCT plg.id)
     
    304305   
    305306    // Context
    306     query.setInteger("itemType", gc.getItem().getValue());
    307     query.setInteger("contextType", gc.getType().getValue());
     307    query.setParameter("itemType", gc.getItem().getValue(), TypeWrapper.H_INTEGER);
     308    query.setParameter("contextType", gc.getType().getValue(), TypeWrapper.H_INTEGER);
    308309
    309310    // Role permissions
    310     query.setBoolean("hasConfigPermission", hasConfigPermission);
    311     query.setBoolean("hasPluginPermission", hasPluginPermission);
     311    query.setParameter("hasConfigPermission", hasConfigPermission, TypeWrapper.H_BOOLEAN);
     312    query.setParameter("hasPluginPermission", hasPluginPermission, TypeWrapper.H_BOOLEAN);
    312313   
    313314    // Owner
    314     query.setInteger("owner", sc.getLoggedInUserId());
     315    query.setParameter("owner", sc.getLoggedInUserId(), TypeWrapper.H_INTEGER);
    315316
    316317    // Shared keys
     
    318319    Set<Integer> itemKeys = sc.getItemKeys(Permission.USE);
    319320    if (itemKeys == null || itemKeys.size() == 0) itemKeys = ZERO_SET;
    320     query.setParameterList("itemKeys", itemKeys, TypeWrapper.INTEGER.getHibernateType());
     321    query.setParameterList("itemKeys", itemKeys, TypeWrapper.H_INTEGER);
    321322
    322323    // Project keys for the active project
     
    324325    if (sc.getActiveProjectId() != 0) projectKeys = sc.getProjectKeys(Permission.USE);
    325326    if (projectKeys == null || projectKeys.size() == 0) projectKeys = ZERO_SET;
    326     query.setParameterList("projectKeys", projectKeys, TypeWrapper.INTEGER.getHibernateType());
    327  
    328     List<Object> pluginCount = HibernateUtil.loadList(Object.class, query, dc.getSessionControl());
     327    query.setParameterList("projectKeys", projectKeys, TypeWrapper.H_INTEGER);
     328 
     329    List<Object[]> pluginCount = HibernateUtil.loadList(query, dc.getSessionControl());
    329330    Map<Plugin.MainType, Integer> result = new HashMap<Plugin.MainType, Integer>(5);
    330     for (Object cnt : pluginCount)
    331     {
    332       Object[] o = (Object[])cnt;
    333       result.put(Plugin.MainType.fromValue((Integer)o[0]), ((Long)o[1]).intValue());
     331    for (Object[] cnt : pluginCount)
     332    {
     333      result.put(Plugin.MainType.fromValue((Integer)cnt[0]), ((Long)cnt[1]).intValue());
    334334    }
    335335   
     
    351351    try
    352352    {
    353       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    354         "GET_PLUGINDEFINITION_FOR_CLASSNAME");
     353      org.hibernate.query.Query<PluginDefinitionData> query = HibernateUtil.getPredefinedQuery(session,
     354        "GET_PLUGINDEFINITION_FOR_CLASSNAME", PluginDefinitionData.class);
    355355     
    356356      for (PluginInfo info : plugins)
    357357      {
    358         query.setString("className", info.getClassName());
    359         PluginDefinitionData plugin = HibernateUtil.loadData(PluginDefinitionData.class, query);
     358        query.setParameter("className", info.getClassName(), TypeWrapper.H_STRING);
     359        PluginDefinitionData plugin = HibernateUtil.loadData(query);
    360360        if (plugin != null)
    361361        {
     
    11671167  public boolean supports(String interfaceName)
    11681168  {
    1169     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    1170       getDbControl().getHibernateSession(), "GET_PLUGINTYPE_FOR_INTERFACENAME");
    1171     query.setString("interfaceName", interfaceName);
    1172     PluginTypeData pt = HibernateUtil.loadData(PluginTypeData.class, query);
     1169    org.hibernate.query.Query<PluginTypeData> query = HibernateUtil.getPredefinedQuery(
     1170      getDbControl().getHibernateSession(), "GET_PLUGINTYPE_FOR_INTERFACENAME", PluginTypeData.class);
     1171    query.setParameter("interfaceName", interfaceName, TypeWrapper.H_STRING);
     1172    PluginTypeData pt = HibernateUtil.loadData(query);
    11731173    return getData().getPluginTypes().contains(pt);
    11741174  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Project.java

    r7373 r7374  
    3333import net.sf.basedb.core.data.ShareableData;
    3434import net.sf.basedb.core.data.SubtypableData;
     35import net.sf.basedb.core.hibernate.TypeWrapper;
    3536import net.sf.basedb.core.query.Restriction;
    3637import net.sf.basedb.core.query.Restrictions;
     
    587588    {
    588589      // Load the project keys for the current project
    589       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEYIDS_FOR_PROJECT");
     590      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEYIDS_FOR_PROJECT", Integer.class);
    590591      /*
    591592        SELECT pk.keyId
     
    593594        WHERE pk.projectId = :projectId
    594595      */
    595       query.setInteger("projectId", this.getId());
    596       projectKeys = new HashSet<Integer>(HibernateUtil.loadList(Integer.class, query, sc));
     596      query.setParameter("projectId", this.getId(), TypeWrapper.H_INTEGER);
     597      projectKeys = new HashSet<Integer>(HibernateUtil.loadList(query, sc));
    597598     
    598599      include.remove(Include.OTHERS);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ProjectKey.java

    r7372 r7374  
    150150        WHERE pk.id NOT IN (:used)
    151151      */
    152       query.setParameterList("used", used, TypeWrapper.INTEGER.getHibernateType());
     152      query.setParameterList("used", used, TypeWrapper.H_INTEGER);
    153153      List<ProjectKeyData> unused = HibernateUtil.loadList(ProjectKeyData.class, query, null);
    154154      for (ProjectKeyData pk : unused)
     
    316316      // have project/permission combinations
    317317      int numPermissions = projectPermissions.size();
    318       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEY_IDS_FOR_COUNT");
     318      org.hibernate.query.Query<Integer> query = HibernateUtil.getPredefinedQuery(session, "GET_PROJECTKEY_IDS_FOR_COUNT", Integer.class);
    319319      /*
    320320        SELECT pk.keyId FROM ProjectKeys pk
     
    322322        HAVING count(pk.projectId) = :numPermissions
    323323      */
    324       query.setInteger("numPermissions", numPermissions);
    325       List<Integer> candidates = HibernateUtil.loadList(Integer.class, query, null);
     324      query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     325      List<Integer> candidates = HibernateUtil.loadList(query, null);
    326326      if (candidates.size() > 0)
    327327      {
     
    342342          "WHERE pk.keyId IN (:candidates) AND ("+sb.toString()+") "+
    343343          "GROUP BY pk.keyId "+
    344           "HAVING COUNT(pk.projectId) = :numPermissions"
     344          "HAVING COUNT(pk.projectId) = :numPermissions", Integer.class
    345345        );
    346         query.setParameterList("candidates", candidates, TypeWrapper.INTEGER.getHibernateType());
    347         query.setInteger("numPermissions", numPermissions);
    348         candidates = HibernateUtil.loadList(Integer.class, query, null);
     346        query.setParameterList("candidates", candidates, TypeWrapper.H_INTEGER);
     347        query.setParameter("numPermissions", numPermissions, TypeWrapper.H_INTEGER);
     348        candidates = HibernateUtil.loadList(query, null);
    349349      }
    350350      if (candidates.size() == 0)
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ProjectSpecificAnnotationsManager.java

    r7372 r7374  
    2828
    2929import net.sf.basedb.core.data.AnnotationData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3031import net.sf.basedb.core.snapshot.SnapshotManager;
    3132
     
    8485  private final List<AnnotationInfo> createdInherited;
    8586 
    86   private org.hibernate.query.Query findProjectSpecific;
     87  private org.hibernate.query.Query<AnnotationData> findProjectSpecific;
    8788
    8889  ProjectSpecificAnnotationsManager(org.hibernate.Session session)
     
    103104    {
    104105      findProjectSpecific = HibernateUtil.getPredefinedQuery(session,
    105         "PS_FIND_PROJECT_SPECIFIC_ANNOTATION");
     106        "PS_FIND_PROJECT_SPECIFIC_ANNOTATION", AnnotationData.class);
    106107      /*
    107108        SELECT ad FROM AnnotationData
     
    110111        AND ad.annotationSet = :annotationSet
    111112      */
    112       findProjectSpecific.setInteger("activeProject", projectId);
    113     }
    114    
    115     findProjectSpecific.setInteger("defaultAnnotation", defaultAnnotation.getId());
    116     findProjectSpecific.setInteger("annotationSet", defaultAnnotation.getData().getAnnotationSet().getId());
    117     AnnotationData psAnnotation = HibernateUtil.loadData(AnnotationData.class, findProjectSpecific);
     113      findProjectSpecific.setParameter("activeProject", projectId, TypeWrapper.H_INTEGER);
     114    }
     115   
     116    findProjectSpecific.setParameter("defaultAnnotation", defaultAnnotation.getId(), TypeWrapper.H_INTEGER);
     117    findProjectSpecific.setParameter("annotationSet", defaultAnnotation.getData().getAnnotationSet().getId(), TypeWrapper.H_INTEGER);
     118    AnnotationData psAnnotation = HibernateUtil.loadData(findProjectSpecific);
    118119    return psAnnotation == null ? null : defaultAnnotation.getDbControl().getItem(Annotation.class, psAnnotation);
    119120  }
     
    197198    if (createdPrimary.size() > 0)
    198199    {
    199       org.hibernate.query.Query defaultQuery = HibernateUtil.getPredefinedSQLQuery(session,
     200      org.hibernate.query.Query<?> defaultQuery = HibernateUtil.getPredefinedSQLQuery(session,
    200201        "PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF");
    201202      /*
     
    206207        AND [source] = 0  AND [project_id] <> 0
    207208      */
    208       org.hibernate.query.Query projectQuery = HibernateUtil.getPredefinedSQLQuery(session,
     209      org.hibernate.query.Query<?> projectQuery = HibernateUtil.getPredefinedSQLQuery(session,
    209210        "PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION");
    210211      /*
     
    224225        {
    225226          // A PRIMARY+DEFAULT annotation -- update override_id on project-specific annotations
    226           defaultQuery.setInteger("annotationId", ai.id);
    227           defaultQuery.setInteger("annotationSetId", ai.annotationSet);
    228           defaultQuery.setInteger("annotationTypeId", ai.annotationType);
     227          defaultQuery.setParameter("annotationId", ai.id, TypeWrapper.H_INTEGER);
     228          defaultQuery.setParameter("annotationSetId", ai.annotationSet, TypeWrapper.H_INTEGER);
     229          defaultQuery.setParameter("annotationTypeId", ai.annotationType, TypeWrapper.H_INTEGER);
    229230          numUpdated += defaultQuery.executeUpdate();
    230231        }
     
    232233        {
    233234          // A PRIMARY+PROJECT-SPECIFIC annotation -- find id of default annotation se we can set override_id
    234           projectQuery.setInteger("annotationId", ai.id);
    235           projectQuery.setInteger("annotationSetId", ai.annotationSet);
    236           projectQuery.setInteger("annotationTypeId", ai.annotationType);
     235          projectQuery.setParameter("annotationId", ai.id, TypeWrapper.H_INTEGER);
     236          projectQuery.setParameter("annotationSetId", ai.annotationSet, TypeWrapper.H_INTEGER);
     237          projectQuery.setParameter("annotationTypeId", ai.annotationType, TypeWrapper.H_INTEGER);
    237238          numUpdated += projectQuery.executeUpdate();
    238239        }
     
    248249    if (createdInherited.size() > 0)
    249250    {
    250       org.hibernate.query.Query defaultQuery = HibernateUtil.getPredefinedSQLQuery(session,
     251      org.hibernate.query.Query<?> defaultQuery = HibernateUtil.getPredefinedSQLQuery(session,
    251252        "PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED");
    252253      /*
     
    260261        )
    261262       */
    262       org.hibernate.query.Query projectQuery = HibernateUtil.getPredefinedSQLQuery(session,
     263      org.hibernate.query.Query<?> projectQuery = HibernateUtil.getPredefinedSQLQuery(session,
    263264        "PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED");
    264265      /*
     
    279280        {
    280281          // An INHERITED+DEFAULT annotation -- update override_id on project-specific annotations
    281           defaultQuery.setInteger("annotationId", ai.id);
    282           defaultQuery.setInteger("annotationSetId", ai.annotationSet);
    283           defaultQuery.setInteger("parentId", ai.parent);
    284           defaultQuery.setInteger("parentSetId", ai.parentSet);
     282          defaultQuery.setParameter("annotationId", ai.id, TypeWrapper.H_INTEGER);
     283          defaultQuery.setParameter("annotationSetId", ai.annotationSet, TypeWrapper.H_INTEGER);
     284          defaultQuery.setParameter("parentId", ai.parent, TypeWrapper.H_INTEGER);
     285          defaultQuery.setParameter("parentSetId", ai.parentSet, TypeWrapper.H_INTEGER);
    285286          numUpdated += defaultQuery.executeUpdate();
    286287        }
     
    288289        {
    289290          // An INHERITED+PROJECT-SPECIFIC annotation -- find id of default annotation se we can set override_id
    290           projectQuery.setInteger("annotationId", ai.id);
    291           projectQuery.setInteger("annotationSetId", ai.annotationSet);
    292           projectQuery.setInteger("parentOverrideId", ai.parentOverride);
     291          projectQuery.setParameter("annotationId", ai.id, TypeWrapper.H_INTEGER);
     292          projectQuery.setParameter("annotationSetId", ai.annotationSet, TypeWrapper.H_INTEGER);
     293          projectQuery.setParameter("parentOverrideId", ai.parentOverride, TypeWrapper.H_INTEGER);
    293294          numUpdated += projectQuery.executeUpdate();
    294295        }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Quantity.java

    r7373 r7374  
    2626import net.sf.basedb.core.data.QuantityData;
    2727import net.sf.basedb.core.data.UnitData;
     28import net.sf.basedb.core.hibernate.TypeWrapper;
    2829import net.sf.basedb.core.query.Hql;
    2930import net.sf.basedb.core.query.Restrictions;
     
    572573  UnitData getUnit(org.hibernate.Session session, String symbol)
    573574  {
    574     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    575         session, "GET_UNIT_WITH_SYMBOL_FOR_QUANTITY");
     575    org.hibernate.query.Query<UnitData> query = HibernateUtil.getPredefinedQuery(
     576        session, "GET_UNIT_WITH_SYMBOL_FOR_QUANTITY", UnitData.class);
    576577    query.setEntity("quantity", this.getData());
    577     query.setString("symbol", symbol);
    578     UnitData unit = HibernateUtil.loadData(UnitData.class, query);
     578    query.setParameter("symbol", symbol, TypeWrapper.H_STRING);
     579    UnitData unit = HibernateUtil.loadData(query);
    579580    return unit;
    580581  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/RawBioAssay.java

    r7373 r7374  
    3232import net.sf.basedb.core.data.SoftwareData;
    3333import net.sf.basedb.core.data.SpotImagesData;
     34import net.sf.basedb.core.hibernate.TypeWrapper;
    3435import net.sf.basedb.core.query.Restrictions;
    3536import net.sf.basedb.core.query.Hql;
     
    12491250        WHERE b.arrayDesign = :arrayDesign
    12501251      */
    1251       query.setInteger("arrayDesign", design.getId());
     1252      query.setParameter("arrayDesign", design.getId(), TypeWrapper.H_INTEGER);
    12521253      ScrollIterator<FeatureData> si = null;
    12531254      try
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/RawDataBatcher.java

    r7373 r7374  
    3030import net.sf.basedb.core.data.ReporterData;
    3131import net.sf.basedb.core.hibernate.ExecuteUpdateWork;
     32import net.sf.basedb.core.hibernate.TypeWrapper;
    3233import net.sf.basedb.core.signal.SignalException;
    3334import net.sf.basedb.core.signal.ThreadSignalHandler;
     
    149150    A query to find reporters by the external id.
    150151  */
    151   private org.hibernate.query.Query findReporter;
     152  private org.hibernate.query.Query<ReporterData> findReporter;
    152153
    153154  /**
     
    501502        {
    502503          org.hibernate.StatelessSession session = getDbControl().getStatelessSession();
    503           findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID");
     504          findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID", ReporterData.class);
    504505        }
    505         findReporter.setString("externalId", externalReporterId);
    506         ReporterData reporter = HibernateUtil.loadData(ReporterData.class, findReporter);
     506        findReporter.setParameter("externalId", externalReporterId, TypeWrapper.H_STRING);
     507        ReporterData reporter = HibernateUtil.loadData(findReporter);
    507508        if (reporter == null)
    508509        {
     
    570571        WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
    571572      */
    572       query.setInteger("arrayDesign", arrayDesign.getId());
     573      query.setParameter("arrayDesign", arrayDesign.getId(), TypeWrapper.H_INTEGER);
    573574      int numFeatures = HibernateUtil.loadData(query).intValue();
    574575      preloaded = new HashMap<Object, FeatureInfo>(numFeatures);
     
    584585        WHERE b.arrayDesign = :arrayDesign
    585586      */
    586       preloadQuery.setInteger("arrayDesign", arrayDesign.getId());
     587      preloadQuery.setParameter("arrayDesign", arrayDesign.getId(), TypeWrapper.H_INTEGER);
    587588      ScrollIterator<FeatureData> si = null;
    588589      try
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/RawDataTypes.java

    r7373 r7374  
    2727import net.sf.basedb.core.data.PlatformVariantData;
    2828import net.sf.basedb.core.dbengine.DbEngine;
     29import net.sf.basedb.core.hibernate.TypeWrapper;
    2930import net.sf.basedb.util.Values;
    3031import net.sf.basedb.util.XmlUtil2;
     
    268269        tx = HibernateUtil.newTransaction(session);
    269270      }
    270       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    271         "GET_PLATFORM_FOR_EXTERNAL_ID");
    272       query.setString("externalId", id.substring(9));
    273       PlatformData platform = HibernateUtil.loadData(PlatformData.class, query);
     271      org.hibernate.query.Query<PlatformData> query = HibernateUtil.getPredefinedQuery(session,
     272        "GET_PLATFORM_FOR_EXTERNAL_ID", PlatformData.class);
     273      query.setParameter("externalId", id.substring(9), TypeWrapper.H_STRING);
     274      PlatformData platform = HibernateUtil.loadData(query);
    274275      if (platform == null || !platform.isFileOnly()) return null;
    275276      rdt = new RawDataType(platform);
     
    300301        tx = HibernateUtil.newTransaction(session);
    301302      }
    302       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    303         "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID");
    304       query.setString("externalId", id.substring(8));
    305       PlatformVariantData variant = HibernateUtil.loadData(PlatformVariantData.class, query);
     303      org.hibernate.query.Query<PlatformVariantData> query = HibernateUtil.getPredefinedQuery(session,
     304        "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID", PlatformVariantData.class);
     305      query.setParameter("externalId", id.substring(8), TypeWrapper.H_STRING);
     306      PlatformVariantData variant = HibernateUtil.loadData(query);
    306307      if (variant == null || !variant.isFileOnly()) return null;
    307308      rdt = new RawDataType(variant);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Reporter.java

    r7372 r7374  
    2828import net.sf.basedb.core.data.ReporterData;
    2929import net.sf.basedb.core.data.ReporterTypeData;
     30import net.sf.basedb.core.hibernate.TypeWrapper;
    3031import net.sf.basedb.core.query.PermissionRestriction;
    3132
     
    111112      String sql = getClonedSelectSql(vdb);
    112113      sql += " where " + HibernateUtil.quote("id") + "=:id";
    113       NativeQuery q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString());
    114       q.setInteger("id", id);
     114      NativeQuery<ReporterData> q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString(), ReporterData.class);
     115      q.setParameter("id", id, TypeWrapper.H_INTEGER);
    115116      q.addEntity(ReporterData.class);
    116       ReporterData rd = HibernateUtil.loadData(ReporterData.class, q);
     117      ReporterData rd = HibernateUtil.loadData(q);
    117118      if (rd == null) throw new ItemNotFoundException("Reporter[id="+id+"]");
    118119      return rd;
     
    150151    }
    151152    org.hibernate.StatelessSession session = dc.getStatelessSession();
    152     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID");
    153     query.setString("externalId", externalId);
    154    
    155     ReporterData rd = HibernateUtil.loadData(ReporterData.class, query);
     153    org.hibernate.query.Query<ReporterData> query = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID", ReporterData.class);
     154    query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     155   
     156    ReporterData rd = HibernateUtil.loadData(query);
    156157    if (rd == null) throw new ItemNotFoundException("Reporter[externalId="+externalId+"]");
    157158    return rd;
     
    187188      String sql = getClonedSelectSql(vdb);
    188189      sql += " where " + HibernateUtil.quote("external_id") + "=:id";
    189       NativeQuery q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString());
    190       q.setString("id", externalId);
     190      NativeQuery<ReporterData> q = HibernateUtil.createSqlQuery(dc.getStatelessSession(), sql.toString(), ReporterData.class);
     191      q.setParameter("id", externalId, TypeWrapper.H_STRING);
    191192      q.addEntity(ReporterData.class);
    192       ReporterData rd = HibernateUtil.loadData(ReporterData.class, q);
     193      ReporterData rd = HibernateUtil.loadData(q);
    193194      if (rd == null) throw new ItemNotFoundException("Reporter[externalId="+externalId+"]");
    194195      return rd;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/ReporterBatcher.java

    r7372 r7374  
    2525
    2626import net.sf.basedb.core.data.ReporterData;
     27import net.sf.basedb.core.hibernate.TypeWrapper;
    2728
    2829import java.util.Date;
     
    188189    A query to find reporters by the external id.
    189190  */
    190   private org.hibernate.query.Query findReporter;
     191  private org.hibernate.query.Query<ReporterData> findReporter;
    191192 
    192193  /**
     
    213214      if (findReporter == null)
    214215      {
    215         findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID");
     216        findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID", ReporterData.class);
    216217      }
    217       findReporter.setString("externalId", externalId);
    218       ReporterData r = HibernateUtil.loadData(ReporterData.class, findReporter);
     218      findReporter.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     219      ReporterData r = HibernateUtil.loadData(findReporter);
    219220      return r != null;
    220221    }
     
    269270    {
    270271      org.hibernate.StatelessSession session = getDbControl().getStatelessSession();
    271       findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID");
    272     }
    273     findReporter.setString("externalId", externalId);
    274     ReporterData r = HibernateUtil.loadData(ReporterData.class, findReporter);
     272      findReporter = HibernateUtil.getPredefinedQuery(session, "GET_REPORTER_FOR_EXTERNAL_ID", ReporterData.class);
     273    }
     274    findReporter.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     275    ReporterData r = HibernateUtil.loadData(findReporter);
    275276    if (r == null && errorIfNotFound) throw new ItemNotFoundException("Reporter[externalId="+externalId+"]");
    276277    return r;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/SessionControl.java

    r7372 r7374  
    3838import net.sf.basedb.core.data.UserClientSettingData;
    3939import net.sf.basedb.core.data.UserDefaultSettingData;
     40import net.sf.basedb.core.hibernate.TypeWrapper;
    4041import net.sf.basedb.core.data.ClientDefaultSettingData;
    4142import net.sf.basedb.core.data.ContextData;
     
    197198       
    198199        // Find the internal client id for the given external id
    199         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_CLIENT_FOR_EXTERNAL_ID");
     200        org.hibernate.query.Query<ClientData> query = HibernateUtil.getPredefinedQuery(session,
     201          "GET_CLIENT_FOR_EXTERNAL_ID", ClientData.class);
    200202        /*
    201203          SELECT cli
     
    203205          WHERE cli.externalId = :externalId
    204206        */
    205         query.setString("externalId", externalClientId);
    206         ClientData clientData = HibernateUtil.loadData(ClientData.class, query);
     207        query.setParameter("externalId", externalClientId, TypeWrapper.H_STRING);
     208        ClientData clientData = HibernateUtil.loadData(query);
    207209        if (clientData != null)
    208210        {
     
    441443    else if (login != null)
    442444    {
    443       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN");
     445      org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN", UserData.class);
    444446      /*
    445447        SELECT usr
     
    447449        WHERE usr.login = :login
    448450      */
    449       query.setString("login", login);
    450       userData = HibernateUtil.loadData(UserData.class, query);
     451      query.setParameter("login", login, TypeWrapper.H_STRING);
     452      userData = HibernateUtil.loadData(query);
    451453      if (userData == null)
    452454      {
     
    719721     
    720722      // Find the internal client id for the given external id
    721       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_CLIENT_FOR_EXTERNAL_ID");
     723      org.hibernate.query.Query<ClientData> query = HibernateUtil.getPredefinedQuery(session, "GET_CLIENT_FOR_EXTERNAL_ID", ClientData.class);
    722724      /*
    723725        SELECT cli
     
    725727        WHERE cli.externalId = :externalId
    726728      */
    727       query.setString("externalId", externalId);
    728       clientData = HibernateUtil.loadData(ClientData.class, query);
     729      query.setParameter("externalId", externalId, TypeWrapper.H_STRING);
     730      clientData = HibernateUtil.loadData(query);
    729731    }
    730732    finally
     
    17881790      session = HibernateUtil.newSession();
    17891791      tx = HibernateUtil.newTransaction(session);
    1790       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_CONTEXT_NAMES");
     1792      org.hibernate.query.Query<Object[]> query = HibernateUtil.getPredefinedQuery(session, "LOAD_CONTEXT_NAMES", Object[].class);
    17911793      /*
    17921794        SELECT ctx.id, ctx.name
     
    17971799        ORDER BY ctx.name
    17981800      */
    1799       query.setInteger("user", loginInfo.userId);
    1800       query.setInteger("client", getClientId());
    1801       query.setInteger("itemType", item.getValue());
    1802       query.setString("subContext", subContext);
    1803       for (Object ctx : HibernateUtil.loadList(Object.class, query, null))
    1804       {
    1805         Object[] o = (Object[])ctx;
    1806         Integer id = (Integer)o[0];
    1807         String name = (String)o[1];
     1801      query.setParameter("user", loginInfo.userId, TypeWrapper.H_INTEGER);
     1802      query.setParameter("client", getClientId(), TypeWrapper.H_INTEGER);
     1803      query.setParameter("itemType", item.getValue(), TypeWrapper.H_INTEGER);
     1804      query.setParameter("subContext", subContext, TypeWrapper.H_STRING);
     1805      for (Object[] ctx : HibernateUtil.loadList(query, null))
     1806      {
     1807        Integer id = (Integer)ctx[0];
     1808        String name = (String)ctx[1];
    18081809        if (!ItemContext.DEFAULT_NAME.equals(name))
    18091810        {
     
    18761877      tx = HibernateUtil.newTransaction(session);
    18771878     
    1878       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_CONTEXT_BY_NAME");
     1879      org.hibernate.query.Query<ContextData> query = HibernateUtil.getPredefinedQuery(session, "LOAD_CONTEXT_BY_NAME", ContextData.class);
    18791880      /*
    18801881        SELECT ctx
     
    18861887        AND ctx.name = :name
    18871888      */
    1888       query.setInteger("user", loginInfo.userId);
    1889       query.setInteger("client", getClientId());
    1890       query.setInteger("itemType", item.getValue());
    1891       query.setString("subContext", subContext);
    1892       query.setString("name", name);
     1889      query.setParameter("user", loginInfo.userId, TypeWrapper.H_INTEGER);
     1890      query.setParameter("client", getClientId(), TypeWrapper.H_INTEGER);
     1891      query.setParameter("itemType", item.getValue(), TypeWrapper.H_INTEGER);
     1892      query.setParameter("subContext", subContext, TypeWrapper.H_STRING);
     1893      query.setParameter("name", name, TypeWrapper.H_STRING);
    18931894     
    1894       ContextData cd = HibernateUtil.loadData(ContextData.class, query);
     1895      ContextData cd = HibernateUtil.loadData(query);
    18951896      if (cd != null)
    18961897      {
     
    19521953        tx = HibernateUtil.newTransaction(session);
    19531954       
    1954         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    1955           "LOAD_USER_CONTEXTS");
     1955        org.hibernate.query.Query<ContextData> query = HibernateUtil.getPredefinedQuery(session,
     1956          "LOAD_USER_CONTEXTS", ContextData.class);
    19561957          /*
    19571958            SELECT ctx
     
    19611962            AND ctx.name = :name
    19621963          */
    1963         query.setInteger("user", loginInfo.userId);
    1964         query.setInteger("client", getClientId());
    1965         query.setString("name", ItemContext.DEFAULT_NAME);
    1966         List<ContextData> contexts = HibernateUtil.loadList(ContextData.class, query, this);
     1964        query.setParameter("user", loginInfo.userId, TypeWrapper.H_INTEGER);
     1965        query.setParameter("client", getClientId(), TypeWrapper.H_INTEGER);
     1966        query.setParameter("name", ItemContext.DEFAULT_NAME, TypeWrapper.H_STRING);
     1967        List<ContextData> contexts = HibernateUtil.loadList(query, this);
    19671968        for (ContextData ctx : contexts)
    19681969        {
     
    20292030        tx = HibernateUtil.newTransaction(session);
    20302031       
    2031         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    2032           "LOAD_USER_CONTEXTS");
     2032        org.hibernate.query.Query<ContextData> query = HibernateUtil.getPredefinedQuery(session,
     2033          "LOAD_USER_CONTEXTS", ContextData.class);
    20332034          /*
    20342035            SELECT ctx
     
    20382039            AND ctx.name = :name
    20392040          */
    2040         query.setInteger("user", loginInfo.userId);
    2041         query.setInteger("client", getClientId());
    2042         query.setString("name", ItemContext.DEFAULT_NAME);
    2043         List<ContextData> contexts = HibernateUtil.loadList(ContextData.class, query, this);
     2041        query.setParameter("user", loginInfo.userId, TypeWrapper.H_INTEGER);
     2042        query.setParameter("client", getClientId(), TypeWrapper.H_INTEGER);
     2043        query.setParameter("name", ItemContext.DEFAULT_NAME, TypeWrapper.H_STRING);
     2044        List<ContextData> contexts = HibernateUtil.loadList(query, this);
    20442045        for (ContextData ctx : contexts)
    20452046        {
     
    22022203  private Map<String, SettingInfo> loadClientDefaultSettings(org.hibernate.Session session, int clientId)
    22032204  {
    2204     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_CLIENT_DEFAULT_SETTINGS");
     2205    org.hibernate.query.Query<ClientDefaultSettingData> query = HibernateUtil.getPredefinedQuery(session,
     2206      "LOAD_CLIENT_DEFAULT_SETTINGS", ClientDefaultSettingData.class);
    22052207    /*
    22062208      SELECT s
     
    22082210      WHERE s.client = :client
    22092211    */
    2210     query.setInteger("client", clientId);
    2211     return listToMap(HibernateUtil.loadList(ClientDefaultSettingData.class, query, null));
     2212    query.setParameter("client", clientId, TypeWrapper.H_INTEGER);
     2213    return listToMap(HibernateUtil.loadList(query, null));
    22122214  }
    22132215
     
    22172219  private Map<String, SettingInfo> loadUserDefaultSettings(org.hibernate.Session session, int userId)
    22182220  {
    2219     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_USER_DEFAULT_SETTINGS");
     2221    org.hibernate.query.Query<UserDefaultSettingData> query = HibernateUtil.getPredefinedQuery(session,
     2222      "LOAD_USER_DEFAULT_SETTINGS", UserDefaultSettingData.class);
    22202223    /*
    22212224      SELECT s
     
    22232226      WHERE s.user = :user
    22242227    */
    2225     query.setInteger("user", userId);
    2226     return listToMap(HibernateUtil.loadList(UserDefaultSettingData.class, query, null));
     2228    query.setParameter("user", userId, TypeWrapper.H_INTEGER);
     2229    return listToMap(HibernateUtil.loadList(query, null));
    22272230  }
    22282231
     
    22322235  private Map<String, SettingInfo> loadUserClientSettings(org.hibernate.Session session, int userId, int clientId)
    22332236  {
    2234     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "LOAD_USER_CLIENT_SETTINGS");
     2237    org.hibernate.query.Query<UserClientSettingData> query = HibernateUtil.getPredefinedQuery(session,
     2238      "LOAD_USER_CLIENT_SETTINGS", UserClientSettingData.class);
    22352239    /*
    22362240      SELECT s
     
    22382242      WHERE s.user = :user AND s.client = client
    22392243    */
    2240     query.setInteger("user", userId);
    2241     query.setInteger("client", clientId);
    2242     return listToMap(HibernateUtil.loadList(UserClientSettingData.class, query, null));
     2244    query.setParameter("user", userId, TypeWrapper.H_INTEGER);
     2245    query.setParameter("client", clientId, TypeWrapper.H_INTEGER);
     2246    return listToMap(HibernateUtil.loadList(query, null));
    22432247  }
    22442248 
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Trashcan.java

    r7373 r7374  
    2626import net.sf.basedb.core.data.BasicData;
    2727import net.sf.basedb.core.data.RemovableData;
     28import net.sf.basedb.core.hibernate.TypeWrapper;
    2829import net.sf.basedb.core.query.Hql;
    2930import net.sf.basedb.core.query.Restriction;
     
    428429      {
    429430        // Query for breaking AnyToAnyLinks between items
    430         org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     431        org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
    431432          "DELETE_ALL_ANYTOANY_TO");
    432433        /*
     
    437438        for (CircularRefInfo c : cRef)
    438439        {
    439           query.setInteger("toId", c.proxy.getId());
    440           query.setInteger("toType", c.proxy.getType().getValue());
     440          query.setParameter("toId", c.proxy.getId(), TypeWrapper.H_INTEGER);
     441          query.setParameter("toType", c.proxy.getType().getValue(), TypeWrapper.H_INTEGER);
    441442          int brokenAnyToAny = query.executeUpdate();
    442443          int brokenRefs = c.proxy.getItem(dc).breakCircularReferences(itemsToRemoveProxy);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Unit.java

    r7373 r7374  
    3333import net.sf.basedb.core.data.UnitData;
    3434import net.sf.basedb.core.data.UnitSymbolData;
     35import net.sf.basedb.core.hibernate.TypeWrapper;
    3536import net.sf.basedb.core.snapshot.SnapshotManager;
    3637import net.sf.basedb.util.formatter.Formatter;
     
    225226    if (action == Transactional.Action.DELETE)
    226227    {
    227       org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(
     228      org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedSQLQuery(
    228229        getDbControl().getHibernateSession(), "SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS");
    229230      /*
     
    232233        WHERE [unit_id] = :unit
    233234      */
    234       query.setInteger("unit", getId());
     235      query.setParameter("unit", getId(), TypeWrapper.H_INTEGER);
    235236      HibernateUtil.executeUpdate(query);
    236237    }
     
    547548       
    548549        String tableName = valueType.getTableName();
    549         org.hibernate.query.Query query = HibernateUtil.getPredefinedSQLQuery(session,
     550        org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedSQLQuery(session,
    550551          "RECALCULATE_ANNOTATIONS_FOR_UNIT", tableName);
    551552        /*
     
    565566          )
    566567        */
    567         query.setInteger("unit", unit.getId());
    568         query.setInteger("valueType", valueType.getValue());
     568        query.setParameter("unit", unit.getId(), TypeWrapper.H_INTEGER);
     569        query.setParameter("valueType", valueType.getValue(), TypeWrapper.H_INTEGER);
    569570       
    570571        // Case 1
    571         query.setInteger("case", 1);
    572         query.setDouble("factor", case1Factor);
    573         query.setDouble("offset", case1Offset);
     572        query.setParameter("case", 1, TypeWrapper.H_INTEGER);
     573        query.setParameter("factor", case1Factor, TypeWrapper.H_DOUBLE);
     574        query.setParameter("offset", case1Offset, TypeWrapper.H_DOUBLE);
    574575        HibernateUtil.executeUpdate(query);
    575576       
    576577        // Case 2
    577         query.setInteger("case", 2);
    578         query.setDouble("factor", case2Factor);
    579         query.setDouble("offset", case2Offset);
     578        query.setParameter("case", 2, TypeWrapper.H_INTEGER);
     579        query.setParameter("factor", case2Factor, TypeWrapper.H_DOUBLE);
     580        query.setParameter("offset", case2Offset, TypeWrapper.H_DOUBLE);
    580581        HibernateUtil.executeUpdate(query);
    581582      }
    582583     
    583584      // We also need to invalidate the annotations in the snapshot cache
    584       org.hibernate.query.Query query = HibernateUtil.createQuery(session,
    585         "SELECT a.annotationSet " +
     585      org.hibernate.query.Query<Integer> query = HibernateUtil.createQuery(session,
     586        "SELECT a.annotationSet.id " +
    586587        "FROM AnnotationData a " +
    587588        "INNER JOIN a.annotationType at " +
    588         "WHERE (a.unit = :unit OR at.defaultUnit = :unit) AND a.unit <> at.defaultUnit");
     589        "WHERE (a.unit = :unit OR at.defaultUnit = :unit) AND a.unit <> at.defaultUnit", Integer.class);
    589590      query.setEntity("unit", unit);
    590       List<AnnotationSetData> tmp = HibernateUtil.loadList(AnnotationSetData.class, query, sc);
    591       for (AnnotationSetData as : tmp)
    592       {
    593         SnapshotManager.removeSnapshot(as.getId());
    594       }
     591      List<Integer> tmp = HibernateUtil.loadList(query, sc);
     592      SnapshotManager.removeSnapshots(tmp);
    595593    }
    596594   
     
    685683  UnitData findOtherUnit(org.hibernate.Session session, String symbol)
    686684  {
    687     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(
    688         session, "GET_UNIT_WITH_SYMBOL_FOR_UNIT");
     685    org.hibernate.query.Query<UnitData> query = HibernateUtil.getPredefinedQuery(
     686        session, "GET_UNIT_WITH_SYMBOL_FOR_UNIT", UnitData.class);
    689687    query.setEntity("unit", this.getData());
    690     query.setString("symbol", symbol);
    691     UnitData unit = HibernateUtil.loadData(UnitData.class, query);
     688    query.setParameter("symbol", symbol, TypeWrapper.H_STRING);
     689    UnitData unit = HibernateUtil.loadData(query);
    692690    return unit;
    693691  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/Update.java

    r7373 r7374  
    7373import net.sf.basedb.core.dbengine.TableInfo.ForeignKeyInfo;
    7474import net.sf.basedb.core.hibernate.TableInfoWork;
     75import net.sf.basedb.core.hibernate.TypeWrapper;
    7576import net.sf.basedb.core.log.ChangeType;
    7677import net.sf.basedb.util.MD5;
     
    711712    org.hibernate.query.Query<SchemaVersionData> query = HibernateUtil.getPredefinedQuery(session,
    712713      "GET_SCHEMA_VERSION_FOR_APP", SchemaVersionData.class);
    713     query.setString("appId", appId);
     714    query.setParameter("appId", appId, TypeWrapper.H_STRING);
    714715    SchemaVersionData data = HibernateUtil.loadData(query);
    715716    int schemaVersion = data == null ? 0 : data.getSchemaVersion();
     
    726727    throws BaseException
    727728  {
    728     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "SET_SCHEMA_VERSION_FOR_APP");
    729     query.setInteger("schemaVersion", schemaVersion);
    730     query.setInteger("build", build);
    731     query.setString("appId", appId);
     729    org.hibernate.query.Query<?> query = HibernateUtil.getPredefinedQuery(session, "SET_SCHEMA_VERSION_FOR_APP");
     730    query.setParameter("schemaVersion", schemaVersion, TypeWrapper.H_INTEGER);
     731    query.setParameter("build", build, TypeWrapper.H_INTEGER);
     732    query.setParameter("appId", appId, TypeWrapper.H_STRING);
    732733    int modified = HibernateUtil.executeUpdate(query);
    733734    if (modified == 0)
     
    823824      {
    824825        // Set appId=net.sf.basedb.core on the only existing schema version entry
    825         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
     826        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
    826827          "UPDATE SchemaVersionData sv " +
    827828          "SET sv.appId = :appId WHERE sv.appId IS NULL");
    828         query.setString("appId", SchemaVersionData.BASE_APP_ID);
     829        query.setParameter("appId", SchemaVersionData.BASE_APP_ID, TypeWrapper.H_STRING);
    829830        query.executeUpdate();
    830831      }
     
    833834      {
    834835        // Set disableInheritance=false on all annotation types
    835         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
     836        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
    836837          "UPDATE AnnotationTypeData at " +
    837838          "SET at.disableInheritance = false " +
     
    843844      {
    844845        // Set source=0 on all existing "Annotations"
    845         org.hibernate.query.Query query = HibernateUtil.createQuery(session,
     846        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
    846847          "UPDATE AnnotationData a " +
    847848          "SET a.source = 0 " +
     
    875876        {
    876877          String tableName = entry.getKey();
    877           org.hibernate.query.Query query;
     878          org.hibernate.query.Query<?> query;
    878879          if (entry.getValue())
    879880          {
     
    885886            String sql = "UPDATE [" + tableName + "] SET [removed_by]=:root, [removed]=false WHERE [removed]=true";
    886887            query = HibernateUtil.createSqlQuery(session, sql);
    887             query.setInteger("root", rootId);
     888            query.setParameter("root", rootId, TypeWrapper.H_INTEGER);
    888889          }
    889890          int updated = query.executeUpdate();
     
    12391240        {
    12401241          // Annotation created: <name> --> ADD + Annotation[<name>]
    1241           fixQuery.setString("ci", "Annotation[" + info.substring("Annotation created: ".length()) + "]");
    1242           fixQuery.setInteger("ct", ChangeType.ADD.getValue());
     1242          fixQuery.setParameter("ci", "Annotation[" + info.substring("Annotation created: ".length()) + "]", TypeWrapper.H_STRING);
     1243          fixQuery.setParameter("ct", ChangeType.ADD.getValue(), TypeWrapper.H_INTEGER);
    12431244        }
    12441245        else if (info.startsWith("Annotation updated: "))
    12451246        {
    12461247          // Annotation updated: <name> --> UPDATE + Annotation[<name>]
    1247           fixQuery.setString("ci", "Annotation[" + info.substring("Annotation updated: ".length()) + "]");
    1248           fixQuery.setInteger("ct", ChangeType.UPDATE.getValue());
     1248          fixQuery.setParameter("ci", "Annotation[" + info.substring("Annotation updated: ".length()) + "]", TypeWrapper.H_STRING);
     1249          fixQuery.setParameter("ct", ChangeType.UPDATE.getValue(), TypeWrapper.H_INTEGER);
    12491250        }
    12501251        else if (info.startsWith("Annotation deleted: "))
    12511252        {
    12521253          // Annotation deleted: <name> --> REMOVE + Annotation[<name>]
    1253           fixQuery.setString("ci", "Annotation[" + info.substring("Annotation deleted: ".length()) + "]");
    1254           fixQuery.setInteger("ct", ChangeType.REMOVE.getValue());
     1254          fixQuery.setParameter("ci", "Annotation[" + info.substring("Annotation deleted: ".length()) + "]", TypeWrapper.H_STRING);
     1255          fixQuery.setParameter("ct", ChangeType.REMOVE.getValue(), TypeWrapper.H_INTEGER);
    12551256        }
    12561257        else if (info.startsWith("File created: "))
    12571258        {
    12581259          // File created: <name> --> ADD + File[<name>]
    1259           fixQuery.setString("ci", "File[" + info.substring("File created: ".length()) + "]");
    1260           fixQuery.setInteger("ct", ChangeType.ADD.getValue());
     1260          fixQuery.setParameter("ci", "File[" + info.substring("File created: ".length()) + "]", TypeWrapper.H_STRING);
     1261          fixQuery.setParameter("ct", ChangeType.ADD.getValue(), TypeWrapper.H_INTEGER);
    12611262        }
    12621263        else if (info.startsWith("File updated: "))
    12631264        {
    12641265          // File updated: <name> --> UPDATE + File[<name>]
    1265           fixQuery.setString("ci", "Annotation[" + info.substring("File updated: ".length()) + "]");
    1266           fixQuery.setInteger("ct", ChangeType.UPDATE.getValue());
     1266          fixQuery.setParameter("ci", "Annotation[" + info.substring("File updated: ".length()) + "]", TypeWrapper.H_STRING);
     1267          fixQuery.setParameter("ct", ChangeType.UPDATE.getValue(), TypeWrapper.H_INTEGER);
    12671268        }
    12681269        else if (info.startsWith("File deleted: "))
    12691270        {
    12701271          // File deleted: <name> --> REMOVE + File[<name>]
    1271           fixQuery.setString("ci", "File[" + info.substring("File deleted: ".length()) + "]");
    1272           fixQuery.setInteger("ct", ChangeType.REMOVE.getValue());
     1272          fixQuery.setParameter("ci", "File[" + info.substring("File deleted: ".length()) + "]", TypeWrapper.H_STRING);
     1273          fixQuery.setParameter("ct", ChangeType.REMOVE.getValue(), TypeWrapper.H_INTEGER);
    12731274        }
    12741275        else if (info.startsWith("Updated: "))
     
    12921293            session.clear();
    12931294          }
    1294           fixQuery.setString("ci", properties[0]);
    1295           fixQuery.setInteger("ct", ChangeType.UPDATE.getValue());
     1295          fixQuery.setParameter("ci", properties[0], TypeWrapper.H_STRING);
     1296          fixQuery.setParameter("ct", ChangeType.UPDATE.getValue(), TypeWrapper.H_INTEGER);
    12961297        }
    12971298        else
     
    13021303        if (fixIt)
    13031304        {
    1304           fixQuery.setInteger("id", change.getId());
     1305          fixQuery.setParameter("id", change.getId(), TypeWrapper.H_INTEGER);
    13051306          fixQuery.executeUpdate();
    13061307        }
     
    13601361          " select " + combinedListFields + ", false, false from [BioMaterialLists]";
    13611362     
    1362       org.hibernate.query.Query query = HibernateUtil.createSqlQuery(session, transferSql);
     1363      org.hibernate.query.Query<?> query = HibernateUtil.createSqlQuery(session, transferSql);
    13631364      int numLists = query.executeUpdate();
    13641365   
     
    13751376      query = HibernateUtil.createSqlQuery(session, propertyFilterSql);
    13761377      // @bioMaterialLists --> §itemLists
    1377       query.setString("oldValue", "@bioMaterialLists");
    1378       query.setString("newValue", "§itemLists");
     1378      query.setParameter("oldValue", "@bioMaterialLists", TypeWrapper.H_STRING);
     1379      query.setParameter("newValue", "§itemLists", TypeWrapper.H_STRING);
    13791380      int numFilters = query.executeUpdate();
    13801381
    13811382      // @bioMaterial.bioMaterialLists --> $mbm.§itemLists
    1382       query.setString("oldValue", "@bioMaterial.bioMaterialLists");
    1383       query.setString("newValue", "$mbm.§itemLists");
     1383      query.setParameter("oldValue", "@bioMaterial.bioMaterialLists", TypeWrapper.H_STRING);
     1384      query.setParameter("newValue", "$mbm.§itemLists", TypeWrapper.H_STRING);
    13841385      numFilters += query.executeUpdate();
    13851386
     
    17041705      QuantityData temperature = HibernateUtil.loadData(session, QuantityData.class, SystemItems.getId(Quantity.TEMPERATURE));
    17051706     
    1706       org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session,
    1707           "GET_UNIT_WITH_NAME_FOR_QUANTITY");
    1708       query.setString("name", "Fahrenheit");
     1707      org.hibernate.query.Query<UnitData> query = HibernateUtil.getPredefinedQuery(session,
     1708          "GET_UNIT_WITH_NAME_FOR_QUANTITY", UnitData.class);
     1709      query.setParameter("name", "Fahrenheit", TypeWrapper.H_STRING);
    17091710      query.setEntity("quantity", temperature);
    1710       UnitData fahrenheit = HibernateUtil.loadData(UnitData.class, query);
     1711      UnitData fahrenheit = HibernateUtil.loadData(query);
    17111712     
    17121713      Unit.changeReferenceFactorAndOffset(null, session, fahrenheit, fahrenheit.getReferenceFactor(), 255.3722);
     
    17491750     
    17501751      // Load all DATE annotation types
    1751       org.hibernate.query.Query query = HibernateUtil.createQuery(statelessSession,
    1752         "SELECT at.name FROM AnnotationTypeData at WHERE at.valueType = " + Type.DATE.getValue());
    1753       List<String> names = HibernateUtil.loadList(String.class, query, null);
     1752      org.hibernate.query.Query<String> nameQuery = HibernateUtil.createQuery(statelessSession,
     1753        "SELECT at.name FROM AnnotationTypeData at WHERE at.valueType = " + Type.DATE.getValue(), String.class);
     1754      List<String> names = HibernateUtil.loadList(nameQuery, null);
    17541755     
    17551756      // Load the entries from ChangeHistoryDetails for each annotation type ordered by entry time
    1756       query = HibernateUtil.createQuery(statelessSession,
     1757      org.hibernate.query.Query<ChangeHistoryDetailData> query = HibernateUtil.createQuery(statelessSession,
    17571758        "SELECT chd FROM ChangeHistoryDetailData chd "+
    17581759        "INNER JOIN chd.changeHistory ch "+
    17591760        "WHERE chd.changeInfo = :info "+
    1760         "ORDER BY ch.time");
     1761        "ORDER BY ch.time", ChangeHistoryDetailData.class);
    17611762     
    17621763      // This query is used to update the 'old_value' for a single change history entry
    1763       org.hibernate.query.Query fixQuery = HibernateUtil.createSqlQuery(statelessSession,
     1764      org.hibernate.query.Query<?> fixQuery = HibernateUtil.createSqlQuery(statelessSession,
    17641765        "update [ChangeHistoryDetails] "+
    17651766        "set [old_value] = :value "+
     
    17711772        if (progress != null) progress.append(".");
    17721773        // Entries related to annotations have the format: Annotation[name]
    1773         query.setString("info", "Annotation["+name+"]");
     1774        query.setParameter("info", "Annotation["+name+"]", TypeWrapper.H_STRING);
    17741775       
    1775         List<ChangeHistoryDetailData> changes = HibernateUtil.loadList(ChangeHistoryDetailData.class, query, null);
     1776        List<ChangeHistoryDetailData> changes = HibernateUtil.loadList(query, null);
    17761777        for (ChangeHistoryDetailData change : changes)
    17771778        {
     
    17871788            {
    17881789              // Yes.. update it!
    1789               fixQuery.setString("value", old.getNewValue());
    1790               fixQuery.setInteger("id", change.getId());
     1790              fixQuery.setParameter("value", old.getNewValue(), TypeWrapper.H_STRING);
     1791              fixQuery.setParameter("id", change.getId(), TypeWrapper.H_INTEGER);
    17911792              fixQuery.executeUpdate();
    17921793            }
     
    19111912     
    19121913      // Load the entries from ChangeHistoryDetails for each annotation type ordered by entry time
    1913       org.hibernate.query.Query query = HibernateUtil.createQuery(statelessSession,
    1914         "SELECT j FROM JobData j " +
    1915         "WHERE j.server IS NOT NULL");
     1914      org.hibernate.query.Query<JobData> query = HibernateUtil.createQuery(statelessSession,
     1915        "SELECT j FROM JobData j ", JobData.class);
    19161916     
    19171917      // This query is used to update the 'server' and 'node' for a single job entry
    1918       org.hibernate.query.Query fixQuery = HibernateUtil.createSqlQuery(statelessSession,
     1918      org.hibernate.query.Query<?> fixQuery = HibernateUtil.createSqlQuery(statelessSession,
    19191919        "update [Jobs] "+
    19201920        "set [server] = :server, [node] = :node "+
    19211921        "where [id] = :id");
    19221922     
    1923       Iterator<JobData> it = HibernateUtil.loadIterator(JobData.class, query, null);
     1923      Iterator<JobData> it = HibernateUtil.loadIterator(query, null);
    19241924      while (it.hasNext())
    19251925      {
     
    19341934          if (node != null && server != null)
    19351935          {
    1936             fixQuery.setString("server", server);
    1937             fixQuery.setString("node", node);
    1938             fixQuery.setInteger("id", job.getId());
     1936            fixQuery.setParameter("server", server, TypeWrapper.H_STRING);
     1937            fixQuery.setParameter("node", node, TypeWrapper.H_STRING);
     1938            fixQuery.setParameter("id", job.getId(), TypeWrapper.H_INTEGER);
    19391939            fixQuery.executeUpdate();
    19401940          }
     
    20062006     
    20072007      // Update the remaining quantity
    2008       org.hibernate.query.Query updateQuery = HibernateUtil.createQuery(session,
     2008      org.hibernate.query.Query<?> updateQuery = HibernateUtil.createQuery(session,
    20092009        "UPDATE MeasuredBioMaterialData mbm " +
    20102010        "SET mbm.remainingQuantity = :remain "+
     
    20192019        {
    20202020          updateQuery.setEntity("bioMaterial", bioMaterial);
    2021           updateQuery.setFloat("remain", remainingQuantity.floatValue());
     2021          updateQuery.setParameter("remain", remainingQuantity.floatValue(), TypeWrapper.H_FLOAT);
    20222022          updateQuery.executeUpdate();
    20232023          numUpdated++;
     
    22362236      org.hibernate.query.Query<ContextData> ctxQuery = HibernateUtil.createQuery(session,
    22372237        "SELECT ctx FROM ContextData ctx WHERE ctx.itemType = :itemType", ContextData.class);
    2238       ctxQuery.setInteger("itemType", itemType);
     2238      ctxQuery.setParameter("itemType", itemType, TypeWrapper.H_INTEGER);
    22392239      for (ContextData ctx : HibernateUtil.loadList(ctxQuery, null))
    22402240      {
     
    22452245      org.hibernate.query.Query<?> deleteQuery = HibernateUtil.getPredefinedSQLQuery(session,
    22462246        "DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE");
    2247       deleteQuery.setInteger("itemType", itemType);
     2247      deleteQuery.setParameter("itemType", itemType, TypeWrapper.H_INTEGER);
    22482248      deleteQuery.executeUpdate();
    22492249     
     
    22522252      deleteQuery = HibernateUtil.getPredefinedSQLQuery(session,
    22532253        "DELETE_PLUGINKEYS_FOR_ITEMTYPE");
    2254       deleteQuery.setInteger("itemType", itemType);
     2254      deleteQuery.setParameter("itemType", itemType, TypeWrapper.H_INTEGER);
    22552255      deleteQuery.executeUpdate();
    22562256
    22572257      org.hibernate.query.Query<RoleKeyData> keyQuery = HibernateUtil.createQuery(session,
    22582258        "SELECT key FROM RoleKeyData key WHERE key.itemType = :itemType", RoleKeyData.class);
    2259       keyQuery.setInteger("itemType", itemType);
     2259      keyQuery.setParameter("itemType", itemType, TypeWrapper.H_INTEGER);
    22602260      for (RoleKeyData key : HibernateUtil.loadList(keyQuery, null))
    22612261      {
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/User.java

    r7373 r7374  
    152152        WHERE ug.groupId IN (:groups)
    153153      */
    154       query.setParameterList("groups", groupIds, TypeWrapper.INTEGER.getHibernateType());
     154      query.setParameterList("groups", groupIds, TypeWrapper.H_INTEGER);
    155155      userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
    156156     
     
    162162        WHERE usr.quotaGroup.id IN (:groups)
    163163      */
    164       query.setParameterList("groups", groupIds, TypeWrapper.INTEGER.getHibernateType());
     164      query.setParameterList("groups", groupIds, TypeWrapper.H_INTEGER);
    165165      userIds.addAll(HibernateUtil.loadList(Integer.class, query, null));
    166166    }
     
    224224    if (login != null) login = login.trim();
    225225    org.hibernate.Session session = dc.getHibernateSession();
    226     org.hibernate.query.Query query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN");
     226    org.hibernate.query.Query<UserData> query = HibernateUtil.getPredefinedQuery(session, "GET_USER_FOR_LOGIN", UserData.class);
    227227    /*
    228228      SELECT usr
     
    230230      WHERE usr.login = :login
    231231    */
    232     query.setString("login", login);
     232    query.setParameter("login", login, TypeWrapper.H_STRING);
    233233    UserData userData = HibernateUtil.loadData(UserData.class, query);
    234234    return userData != null;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/VirtualDb.java

    r7373 r7374  
    2727import net.sf.basedb.core.data.SharedData;
    2828import net.sf.basedb.core.hibernate.ExecuteUpdateWork;
     29import net.sf.basedb.core.hibernate.TypeWrapper;
    2930import net.sf.basedb.util.filter.Filter;
    3031
     
    289290          WHERE vdb.id = :virtualDb
    290291        */
    291         update.setInteger("virtualDb", this.getId());
     292        update.setParameter("virtualDb", this.getId(), TypeWrapper.H_INTEGER);
    292293        HibernateUtil.executeUpdate(update);
    293294       
     
    300301          WHERE vdb.id = :virtualDd
    301302        */
    302         query.setInteger("virtualDb", this.getId());
     303        query.setParameter("virtualDb", this.getId(), TypeWrapper.H_INTEGER);
    303304        cubeNo = HibernateUtil.loadData(query);
    304305        HibernateUtil.commit(tx);
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/hibernate/TypeWrapper.java

    r6898 r7374  
    4848    new TypeWrapper<ShortType>(ShortType.INSTANCE, 2);
    4949
     50  public static final ShortType H_SHORT = ShortType.INSTANCE;
     51 
    5052  public static final TypeWrapper<IntegerType> INTEGER =
    5153    new TypeWrapper<IntegerType>(IntegerType.INSTANCE, 4);
     54
     55  public static final IntegerType H_INTEGER = IntegerType.INSTANCE;
    5256
    5357  public static final TypeWrapper<LongType> LONG =
    5458    new TypeWrapper<LongType>(LongType.INSTANCE, 8);
    5559
     60  public static final LongType H_LONG = LongType.INSTANCE;
     61
    5662  public static final TypeWrapper<FloatType> FLOAT =
    5763    new TypeWrapper<FloatType>(FloatType.INSTANCE, 4);
     64
     65  public static final FloatType H_FLOAT = FloatType.INSTANCE;
    5866
    5967  public static final TypeWrapper<DoubleType> DOUBLE =
    6068    new TypeWrapper<DoubleType>(DoubleType.INSTANCE, 8);
    6169
     70  public static final DoubleType H_DOUBLE = DoubleType.INSTANCE;
     71
    6272  public static final TypeWrapper<StringType> STRING =
    6373    new TypeWrapper<StringType>(StringType.INSTANCE, 0);
     74
     75  public static final StringType H_STRING = StringType.INSTANCE;
    6476
    6577  public static final TypeWrapper<TextType> TEXT =
    6678    new TypeWrapper<TextType>(TextType.INSTANCE, 0);
    6779
     80  public static final TextType H_TEXT = TextType.INSTANCE;
     81
    6882  public static final TypeWrapper<BooleanType> BOOLEAN =
    6983    new TypeWrapper<BooleanType>(BooleanType.INSTANCE, 1);
     84
     85  public static final BooleanType H_BOOLEAN = BooleanType.INSTANCE;
    7086 
    7187  public static final TypeWrapper<DateType> DATE =
    7288    new TypeWrapper<DateType>(DateType.INSTANCE, 4);
    7389
     90  public static final DateType H_DATE = DateType.INSTANCE;
     91
    7492  public static final TypeWrapper<TimestampType> TIMESTAMP =
    7593    new TypeWrapper<TimestampType>(TimestampType.INSTANCE, 4);
    7694
     95  public static final TimestampType H_TIMESTAMP = TimestampType.INSTANCE;
    7796
    7897  private final T hibernateType;
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/db/AnnotationLogger.java

    r7372 r7374  
    4040import net.sf.basedb.core.data.LoggableData;
    4141import net.sf.basedb.core.data.ParameterValueData;
     42import net.sf.basedb.core.hibernate.TypeWrapper;
    4243import net.sf.basedb.core.log.ChangeType;
    4344import net.sf.basedb.core.log.EntityDetails;
     
    112113      if (!Hibernate.isInitialized(at))
    113114      {
    114         Query q = logControl.createHqlQuery(
    115             PredefinedQuery.getQueryString("DBLOG_GET_ANNOTATIONTYPE_INFO"));
    116         q.setInteger("annotationTypeId", at.getId());
    117         Object[] tmp = (Object[])q.uniqueResult();
     115        Query<Object[]> q = logControl.createHqlQuery(
     116            PredefinedQuery.getQueryString("DBLOG_GET_ANNOTATIONTYPE_INFO"), Object[].class);
     117        q.setParameter("annotationTypeId", at.getId(), TypeWrapper.H_INTEGER);
     118        Object[] tmp = q.uniqueResult();
    118119        annotationType = (String)tmp[0];
    119120        valueType = Type.fromValue((Integer)tmp[1]);
     
    131132      if (!Hibernate.isInitialized(as))
    132133      {
    133         Query q = logControl.createHqlQuery(
    134           PredefinedQuery.getQueryString("DBLOG_GET_ANNOTATION_ITEMTYPE"));
    135         q.setInteger("annotationSetId", as.getId());
    136         parentType = (Integer)q.uniqueResult();     
     134        Query<Integer> q = logControl.createHqlQuery(
     135          PredefinedQuery.getQueryString("DBLOG_GET_ANNOTATION_ITEMTYPE"), Integer.class);
     136        q.setParameter("annotationSetId", as.getId(), TypeWrapper.H_INTEGER);
     137        parentType = q.uniqueResult();     
    137138      }
    138139      else
     
    150151
    151152      // Get the id of the parent item
    152       Query q = logControl.createHqlQuery(
    153         PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_ANNOTATION", parentClass.getName()));
    154       q.setInteger("annotationSetId", as.getId());
    155       parentId = (Integer)q.uniqueResult();
     153      Query<Integer> q = logControl.createHqlQuery(
     154        PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_ANNOTATION", parentClass.getName()), Integer.class);
     155      q.setParameter("annotationSetId", as.getId(), TypeWrapper.H_INTEGER);
     156      parentId = q.uniqueResult();
    156157     
    157158      // May happen in case the parent item has been deleted in this transaction
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/db/AnnotationSetLogger.java

    r7372 r7374  
    3232import net.sf.basedb.core.data.ChangeHistoryDetailData;
    3333import net.sf.basedb.core.data.LoggableData;
     34import net.sf.basedb.core.hibernate.TypeWrapper;
    3435import net.sf.basedb.core.log.EntityDetails;
    3536import net.sf.basedb.core.log.ChangeType;
     
    8586    // Get the id of the parent item
    8687    // NOTE! Do not use as.getItemId() since it will be obsolete if the item is deleted
    87     Query q = logControl.createHqlQuery(
    88       PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_ANNOTATION", parentClass.getName()));
    89     q.setInteger("annotationSetId", as.getId());
    90     Integer parentId = (Integer)q.uniqueResult();
     88    Query<Integer> q = logControl.createHqlQuery(
     89      PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_ANNOTATION", parentClass.getName()), Integer.class);
     90    q.setParameter("annotationSetId", as.getId(), TypeWrapper.H_INTEGER);
     91    Integer parentId = q.uniqueResult();
    9192   
    9293    // May happen in case the parent item has been deleted in this transaction
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/db/AnyToAnyLogger.java

    r7372 r7374  
    3333import net.sf.basedb.core.data.LoggableData;
    3434import net.sf.basedb.core.data.NameableData;
     35import net.sf.basedb.core.hibernate.TypeWrapper;
    3536import net.sf.basedb.core.log.ChangeType;
    3637import net.sf.basedb.core.log.EntityDetails;
     
    157158    {
    158159      // Query the database for the name
    159       Query q = logControl.createHqlQuery(
    160         PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", itemType.getDataClass().getName()));
    161       q.setInteger("id", itemId);
    162       String name = (String)q.uniqueResult();
     160      Query<String> q = logControl.createHqlQuery(
     161        PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", itemType.getDataClass().getName()), String.class);
     162      q.setParameter("id", itemId, TypeWrapper.H_INTEGER);
     163      String name = q.uniqueResult();
    163164      log += "[" + name + "]";
    164165    }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/db/FileSetMemberLogger.java

    r7372 r7374  
    3535import net.sf.basedb.core.data.FileSetMemberData;
    3636import net.sf.basedb.core.data.LoggableData;
     37import net.sf.basedb.core.hibernate.TypeWrapper;
    3738import net.sf.basedb.core.log.ChangeType;
    3839import net.sf.basedb.core.log.EntityDetails;
     
    7475    if (!Hibernate.isInitialized(ft))
    7576    {
    76       Query q = logControl.createHqlQuery(
    77           PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", "DataFileTypeData"));
    78       q.setInteger("id", ft.getId());
    79       fileType = (String)q.uniqueResult();
     77      Query<String> q = logControl.createHqlQuery(
     78          PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", "DataFileTypeData"), String.class);
     79      q.setParameter("id", ft.getId(), TypeWrapper.H_INTEGER);
     80      fileType = q.uniqueResult();
    8081    }
    8182    else
     
    8990    if (!Hibernate.isInitialized(fs))
    9091    {
    91       Query q = logControl.createHqlQuery(
    92         PredefinedQuery.getQueryString("DBLOG_GET_FILESET_ITEMTYPE"));
    93       q.setInteger("fileSetId", fs.getId());
    94       parentType = (Integer)q.uniqueResult();     
     92      Query<Integer> q = logControl.createHqlQuery(
     93        PredefinedQuery.getQueryString("DBLOG_GET_FILESET_ITEMTYPE"), Integer.class);
     94      q.setParameter("fileSetId", fs.getId(), TypeWrapper.H_INTEGER);
     95      parentType = q.uniqueResult();     
    9596    }
    9697    else
     
    108109   
    109110    // Get the id of the parent item
    110     Query q = logControl.createHqlQuery(
    111       PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_FILESET", parentClass.getName()));
    112     q.setInteger("fileSetId", fs.getId());
    113     Integer parentId = (Integer)q.uniqueResult();
     111    Query<Integer> q = logControl.createHqlQuery(
     112      PredefinedQuery.getQueryString("DBLOG_GET_ITEMID_WITH_FILESET", parentClass.getName()), Integer.class);
     113    q.setParameter("fileSetId", fs.getId(), TypeWrapper.H_INTEGER);
     114    Integer parentId = q.uniqueResult();
    114115   
    115116    // May happen in case the parent item has been deleted in this transaction
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/log/db/PlateEventLogger.java

    r7372 r7374  
    3131import net.sf.basedb.core.data.PlateEventData;
    3232import net.sf.basedb.core.data.PlateEventTypeData;
     33import net.sf.basedb.core.hibernate.TypeWrapper;
    3334import net.sf.basedb.core.log.EntityDetails;
    3435import net.sf.basedb.core.log.ChangeType;
     
    7677    if (!Hibernate.isInitialized(et))
    7778    {
    78       Query q = logControl.createHqlQuery(
    79           PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", "PlateEventTypeData"));
    80       q.setInteger("id", et.getId());
    81       eventType = (String)q.uniqueResult();
     79      Query<String> q = logControl.createHqlQuery(
     80          PredefinedQuery.getQueryString("DBLOG_GET_NAME_FOR_ITEM", "PlateEventTypeData"), String.class);
     81      q.setParameter("id", et.getId(), TypeWrapper.H_INTEGER);
     82      eventType = q.uniqueResult();
    8283    }
    8384    else
Note: See TracChangeset for help on using the changeset viewer.