Search in sources :

Example 1 with ExtendedTypeEntity

use of org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity in project cayenne by apache.

the class DataContextExtendedTypeOperationsIT method testInExpressionExtendedTypeArray.

@Test
public void testInExpressionExtendedTypeArray() {
    ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
    e1.setName(new StringET1("X"));
    ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
    e2.setName(new StringET1("Y"));
    ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
    e3.setName(new StringET1("Z"));
    e1.getObjectContext().commitChanges();
    Expression in = ExtendedTypeEntity.NAME.in(new StringET1("X"), new StringET1("Y"));
    SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
    assertEquals(2, e1.getObjectContext().performQuery(query).size());
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) Expression(org.apache.cayenne.exp.Expression) ExtendedTypeEntity(org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity) StringET1(org.apache.cayenne.testdo.extended_type.StringET1) Test(org.junit.Test)

Example 2 with ExtendedTypeEntity

use of org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity in project cayenne by apache.

the class DataContextExtendedTypeOperationsIT method testInExpressionExtendedTypeList.

@Test
public void testInExpressionExtendedTypeList() {
    ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
    e1.setName(new StringET1("X"));
    ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
    e2.setName(new StringET1("Y"));
    ExtendedTypeEntity e3 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
    e3.setName(new StringET1("Z"));
    e1.getObjectContext().commitChanges();
    Expression in = ExtendedTypeEntity.NAME.in(Arrays.asList(new StringET1("X"), new StringET1("Y")));
    SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
    assertEquals(2, e1.getObjectContext().performQuery(query).size());
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) Expression(org.apache.cayenne.exp.Expression) ExtendedTypeEntity(org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity) StringET1(org.apache.cayenne.testdo.extended_type.StringET1) Test(org.junit.Test)

Example 3 with ExtendedTypeEntity

use of org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity in project cayenne by apache.

the class DataContextExtendedTypeOperationsIT method testStoreExtendedType.

@Test
public void testStoreExtendedType() {
    ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
    e1.setName(new StringET1("X"));
    e1.getObjectContext().commitChanges();
    SQLTemplate checkQ = new SQLTemplate(ExtendedTypeEntity.class, "SELECT * FROM EXTENDED_TYPE_TEST WHERE NAME = 'X'");
    checkQ.setFetchingDataRows(true);
    checkQ.setColumnNamesCapitalization(CapsStrategy.UPPER);
    assertEquals(1, e1.getObjectContext().performQuery(checkQ).size());
}
Also used : SQLTemplate(org.apache.cayenne.query.SQLTemplate) ExtendedTypeEntity(org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity) StringET1(org.apache.cayenne.testdo.extended_type.StringET1) Test(org.junit.Test)

Aggregations

ExtendedTypeEntity (org.apache.cayenne.testdo.extended_type.ExtendedTypeEntity)3 StringET1 (org.apache.cayenne.testdo.extended_type.StringET1)3 Test (org.junit.Test)3 Expression (org.apache.cayenne.exp.Expression)2 SelectQuery (org.apache.cayenne.query.SelectQuery)2 SQLTemplate (org.apache.cayenne.query.SQLTemplate)1