Search in sources :

Example 6 with Ordering

use of org.apache.cayenne.query.Ordering in project cayenne by apache.

the class OrderingTranslatorIT method testAppendFunctionExpression1.

@Test
public void testAppendFunctionExpression1() throws Exception {
    Ordering o1 = new Ordering(FunctionExpressionFactory.absExp("paintingArray.estimatedPrice"));
    doTestAppendPart("ABS(ta.ESTIMATED_PRICE)", o1);
}
Also used : Ordering(org.apache.cayenne.query.Ordering) Test(org.junit.Test)

Example 7 with Ordering

use of org.apache.cayenne.query.Ordering in project cayenne by apache.

the class OrderingTranslatorIT method testAppendIllegalExpression.

@Test(expected = CayenneRuntimeException.class)
public void testAppendIllegalExpression() throws Exception {
    Ordering o1 = new Ordering(ExpressionFactory.and(ExpressionFactory.expTrue(), ExpressionFactory.expFalse()));
    // should throw exception
    doTestAppendPart("TRUE AND FALSE", o1);
}
Also used : Ordering(org.apache.cayenne.query.Ordering) Test(org.junit.Test)

Example 8 with Ordering

use of org.apache.cayenne.query.Ordering in project cayenne by apache.

the class OrderingTranslatorIT method testAppendPart1.

/**
 * Tests ascending ordering on string attribute.
 */
@Test
public void testAppendPart1() throws Exception {
    Ordering o1 = new Ordering("artistName", SortOrder.ASCENDING);
    doTestAppendPart("ta.ARTIST_NAME", o1);
}
Also used : Ordering(org.apache.cayenne.query.Ordering) Test(org.junit.Test)

Example 9 with Ordering

use of org.apache.cayenne.query.Ordering in project cayenne by apache.

the class OrderingTranslatorIT method testAppendPart2.

/**
 * Tests descending ordering on string attribute.
 */
@Test
public void testAppendPart2() throws Exception {
    Ordering o1 = new Ordering("artistName", SortOrder.DESCENDING);
    doTestAppendPart("ta.ARTIST_NAME DESC", o1);
}
Also used : Ordering(org.apache.cayenne.query.Ordering) Test(org.junit.Test)

Example 10 with Ordering

use of org.apache.cayenne.query.Ordering in project cayenne by apache.

the class OrderingTranslatorIT method testAppendPart3.

@Test
public void testAppendPart3() throws Exception {
    Ordering o1 = new Ordering("artistName", SortOrder.DESCENDING);
    Ordering o2 = new Ordering("paintingArray.estimatedPrice", SortOrder.ASCENDING);
    doTestAppendPart("ta.ARTIST_NAME DESC, ta.ESTIMATED_PRICE", o1, o2);
}
Also used : Ordering(org.apache.cayenne.query.Ordering) Test(org.junit.Test)

Aggregations

Ordering (org.apache.cayenne.query.Ordering)18 Test (org.junit.Test)10 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)2 SelectQuery (org.apache.cayenne.query.SelectQuery)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 Expression (org.apache.cayenne.exp.Expression)1 ExpressionException (org.apache.cayenne.exp.ExpressionException)1 DataMap (org.apache.cayenne.map.DataMap)1 Entity (org.apache.cayenne.map.Entity)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 SelectQueryDescriptor (org.apache.cayenne.map.SelectQueryDescriptor)1 Query (org.apache.cayenne.query.Query)1 SortOrder (org.apache.cayenne.query.SortOrder)1 SimpleLockingTestEntity (org.apache.cayenne.testdo.locking.SimpleLockingTestEntity)1 Artist (org.apache.cayenne.testdo.testmap.Artist)1 CayenneMapEntry (org.apache.cayenne.util.CayenneMapEntry)1