Commit 33f36d56 authored by Matija Obreza's avatar Matija Obreza
Browse files

Don't join FaoInstitute if not needed, avoid NPE in #sort

parent 1896e3d0
...@@ -99,28 +99,28 @@ public class DirectMysqlQuery { ...@@ -99,28 +99,28 @@ public class DirectMysqlQuery {
protected DirectMysqlQuery join(AppliedFilters filters) { protected DirectMysqlQuery join(AppliedFilters filters) {
if (hasFilter(filters, FilterConstants.CROPS) || hasFilter(filters, FilterConstants.TAXONOMY_GENUS) if (hasFilter(filters, FilterConstants.CROPS) || hasFilter(filters, FilterConstants.TAXONOMY_GENUS)
|| hasFilter(filters, FilterConstants.TAXONOMY_SPECIES) || hasFilter(filters, FilterConstants.TAXONOMY_SCINAME)) { || hasFilter(filters, FilterConstants.TAXONOMY_SPECIES) || hasFilter(filters, FilterConstants.TAXONOMY_SCINAME)) {
innerJoin("taxonomy2", "t", "t.id=a.taxonomyId2"); innerJoin("taxonomy2", "t", "t.id=a.taxonomyId2");
if (hasFilter(filters, FilterConstants.CROPS)) { if (hasFilter(filters, FilterConstants.CROPS)) {
innerJoin("croptaxonomy", "ct", "ct.taxonomyId=t.id"); innerJoin("croptaxonomy", "ct", "ct.taxonomyId=t.id");
innerJoin("crop", null, "crop.id=ct.cropId"); innerJoin("crop", null, "crop.id=ct.cropId");
} }
} }
// if (hasFilter(filters, FilterConstants.ORGCTY_ISO3)) { // if (hasFilter(filters, FilterConstants.ORGCTY_ISO3)) {
// innerJoin("country", "cty", "cty.id=a.orgCtyId"); // innerJoin("country", "cty", "cty.id=a.orgCtyId");
// } // }
if (hasFilter(filters, FilterConstants.INSTCODE) || hasFilter(filters, FilterConstants.INSTITUTE_COUNTRY_ISO3) if (/* hasFilter(filters, FilterConstants.INSTCODE) || */hasFilter(filters, FilterConstants.INSTITUTE_COUNTRY_ISO3)
|| hasFilter(filters, FilterConstants.INSTITUTE_NETWORK)) { || hasFilter(filters, FilterConstants.INSTITUTE_NETWORK)) {
innerJoin("faoinstitute", "fao", "fao.id=a.instituteId"); innerJoin("faoinstitute", "fao", "fao.id=a.instituteId");
if (hasFilter(filters, FilterConstants.INSTITUTE_COUNTRY_ISO3)) { if (hasFilter(filters, FilterConstants.INSTITUTE_COUNTRY_ISO3)) {
innerJoin("country", "faocty", "faocty.id=fao.countryId"); innerJoin("country", "faocty", "faocty.id=fao.countryId");
} }
if (hasFilter(filters, FilterConstants.INSTITUTE_NETWORK)) { if (hasFilter(filters, FilterConstants.INSTITUTE_NETWORK)) {
innerJoin("organizationinstitute", "oi", "oi.instituteId=fao.id"); innerJoin("organizationinstitute", "oi", "oi.instituteId=fao.id");
innerJoin("organization", "org", "org.id=oi.organizationId"); innerJoin("organization", "org", "org.id=oi.organizationId");
...@@ -421,6 +421,10 @@ public class DirectMysqlQuery { ...@@ -421,6 +421,10 @@ public class DirectMysqlQuery {
} }
public DirectMysqlQuery sort(Sort sort) { public DirectMysqlQuery sort(Sort sort) {
if (sort == null) {
return this;
}
if (sortBuffer.length() != 0) { if (sortBuffer.length() != 0) {
throw new RuntimeException("sortBuffer is not blank, invalid use of #pageable(Pageable)"); throw new RuntimeException("sortBuffer is not blank, invalid use of #pageable(Pageable)");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment