use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class NumericTypesIT method testBigDecimal.
@Test
public void testBigDecimal() throws Exception {
BigDecimalEntity test = context.newObject(BigDecimalEntity.class);
BigDecimal i = new BigDecimal("1234567890.44");
test.setBigDecimalField(i);
context.commitChanges();
SelectQuery<BigDecimalEntity> q = new SelectQuery<>(BigDecimalEntity.class);
BigDecimalEntity testRead = (BigDecimalEntity) context.performQuery(q).get(0);
assertNotNull(testRead.getBigDecimalField());
assertEquals(i, testRead.getBigDecimalField());
test.setBigDecimalField(null);
context.commitChanges();
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class QuotedIdentifiersIT method testPrefetchQuote.
@Test
public void testPrefetchQuote() throws Exception {
DbEntity entity = context.getEntityResolver().getObjEntity(QuoteAdress.class).getDbEntity();
List idAttributes = Collections.singletonList(entity.getAttribute("City"));
List updatedAttributes = Collections.singletonList(entity.getAttribute("City"));
UpdateBatchQuery updateQuery = new UpdateBatchQuery(entity, idAttributes, updatedAttributes, Collections.<String>emptySet(), 1);
List objects3 = context.performQuery(updateQuery);
assertEquals(0, objects3.size());
SelectQuery qQuote_Person2 = new SelectQuery(Quote_Person.class);
List objects4 = context.performQuery(qQuote_Person2);
assertEquals(2, objects4.size());
SelectQuery qQuote_Person3 = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("salary", 100));
List objects5 = context.performQuery(qQuote_Person3);
assertEquals(1, objects5.size());
SelectQuery qQuote_Person4 = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("group", "107324"));
List objects6 = context.performQuery(qQuote_Person4);
assertEquals(1, objects6.size());
SelectQuery quoteAdress1 = new SelectQuery(QuoteAdress.class, ExpressionFactory.matchExp("group", "324"));
List objects7 = context.performQuery(quoteAdress1);
assertEquals(1, objects7.size());
ObjectIdQuery queryObjectId = new ObjectIdQuery(new ObjectId("QuoteAdress", QuoteAdress.GROUP.getName(), "324"));
List objects8 = context.performQuery(queryObjectId);
assertEquals(1, objects8.size());
ObjectIdQuery queryObjectId2 = new ObjectIdQuery(new ObjectId("Quote_Person", "GROUP", "1111"));
List objects9 = context.performQuery(queryObjectId2);
assertEquals(1, objects9.size());
SelectQuery person2Query = new SelectQuery(Quote_Person.class, ExpressionFactory.matchExp("name", "Name"));
Quote_Person quote_Person2 = (Quote_Person) context.performQuery(person2Query).get(0);
RelationshipQuery relationshipQuery = new RelationshipQuery(quote_Person2.getObjectId(), "address_Rel");
List objects10 = context.performQuery(relationshipQuery);
assertEquals(1, objects10.size());
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testFLOAT2.
@Test
public void testFLOAT2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Float floatValue = 375.437f;
test.setFloatColumn(floatValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Float columnValue = testRead.getFloatColumn();
assertNotNull(columnValue);
assertEquals(Float.class, columnValue.getClass());
assertEquals(floatValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testDOUBLE2.
@Test
public void testDOUBLE2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Double doubleValue = 3298.4349783d;
test.setDoubleColumn(doubleValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Double columnValue = testRead.getDoubleColumn();
assertNotNull(columnValue);
assertEquals(Double.class, columnValue.getClass());
assertEquals(doubleValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testBIGINT2.
@Test
public void testBIGINT2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Long bigintValue = 5326457654783454355l;
test.setBigintColumn(bigintValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Long columnValue = testRead.getBigintColumn();
assertNotNull(columnValue);
assertEquals(Long.class, columnValue.getClass());
assertEquals(bigintValue, columnValue);
}
Aggregations