Changeset 3776


Ignore:
Timestamp:
Sep 25, 2007, 11:28:10 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #781: AnnotationSet?.getAllInheritedAnnotations() may generate invalid query on Postgres

Location:
branches/2.4-stable
Files:
2 edited

Legend:

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

    r3675 r3776  
    283283   
    284284    // Load 'Required for MIAME' annotation types (parameter='false' must also be set)
    285     ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), "name");
     285    ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), null, "name");
    286286    query.restrict(
    287287      Restrictions.eq(
     
    556556    Node efNode = new Node("experimental.factors", "Experimental factors", rootNode);
    557557    Experiment experiment = (Experiment)rootNode.getItem();
    558     ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), "name");
     558    ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), null, "name");
    559559    for (AnnotationType ef : efQuery.list(dc))
    560560    {
     
    574574    Node rawBioAssaysNode = new Node("rawbioassays", "Raw bioassays", rootNode);
    575575    Experiment experiment = (Experiment)rootNode.getItem();
    576     ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), "name");
     576    ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), null, "name");
    577577    Set<BasicItem> arrayDesigns = new HashSet<BasicItem>();
    578578    for (RawBioAssay rba : rbaQuery.list(dc))
     
    801801    Node imagesNode = new Node("images", "Images", scanNode);
    802802    Scan scan = (Scan)scanNode.getItem();
    803     ItemQuery<Image> imageQuery = initQuery(scan.getImages(), "name");
     803    ItemQuery<Image> imageQuery = initQuery(scan.getImages(), null, "name");
    804804    for (Image image : imageQuery.list(dc))
    805805    {
     
    831831    Hybridization hyb = (Hybridization)hybNode.getItem();
    832832    ItemQuery<LabeledExtract> leQuery =
    833       (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), "label.name");
     833      (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), null, "label.name");
    834834    int added = 0;
    835835    int channels = experiment.getRawDataType().getChannels();
     
    935935   
    936936    ItemQuery<LabeledExtract> sourceQuery =
    937       initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), "name");
     937      initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), null, "name");
    938938   
    939939    int added = 0;
     
    10581058   
    10591059    ItemQuery<Extract> sourceQuery =
    1060       initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), "name");
     1060      initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), null, "name");
    10611061   
    10621062    int added = 0;
     
    11621162   
    11631163    ItemQuery<Sample> sourceQuery =
    1164       initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), "name");
     1164      initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), null, "name");
    11651165   
    11661166    int added = 0;
     
    15341534    AnnotationSet as = annotatable != null && annotatable.isAnnotated() ?
    15351535        annotatable.getAnnotationSet() : null;
    1536     ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), "name");
     1536    ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), null, "name");
    15371537    List<AnnotationType> parameters = parameterQuery.list(dc);
    15381538    Node parameterNode = null;
     
    15821582      annotationsNode = new Node("annotations", "Annotations", parentNode);
    15831583      AnnotationSet as = parent.getAnnotationSet();
    1584       ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), "annotationType.name");
     1584      ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), null, "annotationType.name");
    15851585   
    15861586      for (Annotation a : annotationQuery.list(dc))
     
    16621662      annotationTypes.clear();
    16631663      AnnotationSet as = parent.getAnnotationSet();
    1664       ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "annotationType.name");
     1664      ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "at", "name");
     1665      annotationQuery.join(Hql.innerJoin(null, "annotationType", "at", true));
    16651666      List<Annotation> inherited = annotationQuery.list(dc);
    16661667      if (inherited.size() > 0)
     
    17271728    Set include options and sorting order for a query.
    17281729  */
    1729   private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sortProperty)
     1730  private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sortAlias, String sortProperty)
    17301731  {
    17311732    query.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
    1732     query.order(Orders.asc(Hql.property(sortProperty)));
     1733    query.order(Orders.asc(Hql.property(sortAlias, sortProperty)));
    17331734    return query;
    17341735  }
  • branches/2.4-stable/www/common/annotations/list_annotations.jsp

    r3679 r3776  
    8383  {
    8484    ItemQuery<Annotation> inheritedQuery = as.getAllInheritedAnnotations();
     85    // Need FETCH JOIN because Postgres don't like the DISTINCT keyword
     86    // if we sort on a non-selected column See ticket #731
     87    inheritedQuery.join(Hql.innerJoin(null, "annotationType", "at", true));
    8588    inheritedQuery.order(Orders.asc(Hql.property("annotationSet")));
    86     inheritedQuery.order(Orders.asc(Hql.property("annotationType.name")));
     89    inheritedQuery.order(Orders.asc(Hql.property("at", "name")));
    8790    inheritedAnnotations = inheritedQuery.list(dc);
    8891  }
Note: See TracChangeset for help on using the changeset viewer.