mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
#174 Add nullsFirst and nullsLast serialization to JPA
This commit is contained in:
parent
79afee0c79
commit
499b8d7761
@ -48,6 +48,7 @@ import com.mysema.query.types.FactoryExpression;
|
||||
import com.mysema.query.types.Operation;
|
||||
import com.mysema.query.types.Operator;
|
||||
import com.mysema.query.types.Ops;
|
||||
import com.mysema.query.types.Order;
|
||||
import com.mysema.query.types.OrderSpecifier;
|
||||
import com.mysema.query.types.ParamExpression;
|
||||
import com.mysema.query.types.Path;
|
||||
@ -226,7 +227,12 @@ public class JPQLSerializer extends SerializerBase<JPQLSerializer> {
|
||||
append(COMMA);
|
||||
}
|
||||
handle(os.getTarget());
|
||||
append(" " + os.getOrder().toString().toLowerCase(Locale.ENGLISH));
|
||||
append(os.getOrder() == Order.ASC ? " asc" : " desc");
|
||||
if (os.getNullHandling() == OrderSpecifier.NullHandling.NullsFirst) {
|
||||
append(" nulls first");
|
||||
} else if (os.getNullHandling() == OrderSpecifier.NullHandling.NullsLast) {
|
||||
append(" nulls last");
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,6 +749,20 @@ public abstract class AbstractStandardTest {
|
||||
NumberPath<Double> weight = new NumberPath<Double>(Double.class, "weight");
|
||||
query().from(cat).orderBy(weight.asc()).list(cat.bodyWeight.as(weight));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Order_NullsFirst() {
|
||||
query().from(cat)
|
||||
.orderBy(cat.name.asc().nullsFirst())
|
||||
.list(cat);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Order_NullsLast() {
|
||||
query().from(cat)
|
||||
.orderBy(cat.name.asc().nullsLast())
|
||||
.list(cat);
|
||||
}
|
||||
|
||||
@Test
|
||||
@NoOpenJPA // FIXME
|
||||
|
||||
Loading…
Reference in New Issue
Block a user