Search in sources :

Example 1 with Ordering

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

the class OrderingTranslatorIT method testAppendPart4.

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

Example 2 with Ordering

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

the class OrderingTranslatorIT method testAppendPart5.

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

Example 3 with Ordering

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

the class OrderingTranslatorIT method testAppendPart6.

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

Example 4 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 5 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)

Aggregations

Ordering (org.apache.cayenne.query.Ordering)20 Test (org.junit.Test)10 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)2 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)2 DataMap (org.apache.cayenne.map.DataMap)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Expression (org.apache.cayenne.exp.Expression)1 ExpressionException (org.apache.cayenne.exp.ExpressionException)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbEntity (org.apache.cayenne.map.DbEntity)1 Entity (org.apache.cayenne.map.Entity)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1 SelectQueryDescriptor (org.apache.cayenne.map.SelectQueryDescriptor)1 Query (org.apache.cayenne.query.Query)1 SelectQuery (org.apache.cayenne.query.SelectQuery)1 SortOrder (org.apache.cayenne.query.SortOrder)1