mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
Refs #1407 Table sorting: sort by reference column with null value
This commit is contained in:
parent
10f4c8c067
commit
9c584198bb
@ -482,6 +482,19 @@ public abstract class AbstractCollectionDatasource<T extends Entity<K>, K>
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSortDirection(LoadContext.Query q) {
|
||||
boolean asc = Sortable.Order.ASC.equals(sortInfos[0].getOrder());
|
||||
MetaPropertyPath propertyPath = sortInfos[0].getPropertyPath();
|
||||
// Sort on DB only if the property is not transient and it is not an entity. Sorting by entity in JPQL
|
||||
// translates to order by entity's id in SQL, that makes no sense.
|
||||
if (MetadataHelper.isPersistent(propertyPath) && !propertyPath.getMetaProperty().getRange().isClass()) {
|
||||
QueryTransformer transformer = QueryTransformerFactory.createTransformer(q.getQueryString(), metaClass.getName());
|
||||
transformer.replaceOrderBy(propertyPath.toString(), !asc);
|
||||
String jpqlQuery = transformer.getResult();
|
||||
q.setQueryString(jpqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
private class ComponentValueListener implements ValueListener {
|
||||
public void valueChanged(Object source, String property, Object prevValue, Object value) {
|
||||
refresh();
|
||||
|
@ -496,17 +496,6 @@ public class CollectionDatasourceImpl<T extends Entity<K>, K>
|
||||
detachListener((Instance) obj);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSortDirection(LoadContext.Query q) {
|
||||
boolean asc = Order.ASC.equals(sortInfos[0].getOrder());
|
||||
MetaPropertyPath propertyPath = sortInfos[0].getPropertyPath();
|
||||
if (MetadataHelper.isPersistent(propertyPath)) {
|
||||
QueryTransformer transformer = QueryTransformerFactory.createTransformer(q.getQueryString(), metaClass.getName());
|
||||
transformer.replaceOrderBy(propertyPath.toString(), !asc);
|
||||
String jpqlQuery = transformer.getResult();
|
||||
q.setQueryString(jpqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Object, String> aggregate(AggregationInfo[] aggregationInfos, Collection itemIds) {
|
||||
|
@ -359,15 +359,7 @@ public class LazyCollectionDatasource<T extends Entity<K>, K>
|
||||
LoadContext.Query q = createLoadContextQuery(ctx, params);
|
||||
if (q != null) {
|
||||
if (sortInfos != null) {
|
||||
QueryTransformer transformer = QueryTransformerFactory.createTransformer(q.getQueryString(), metaClass.getName());
|
||||
|
||||
boolean asc = Order.ASC.equals(sortInfos[0].getOrder());
|
||||
MetaPropertyPath propertyPath = sortInfos[0].getPropertyPath();
|
||||
|
||||
transformer.replaceOrderBy(propertyPath.toString(), !asc);
|
||||
String jpqlQuery = transformer.getResult();
|
||||
|
||||
q.setQueryString(jpqlQuery);
|
||||
setSortDirection(q);
|
||||
}
|
||||
|
||||
if (maxResults == 0 || data.size() < maxResults) {
|
||||
|
Loading…
Reference in New Issue
Block a user