use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class EJBQLQueryIT method testRelationshipWhereClause.
// SELECT COUNT(p) from Product p where p.vsCatalog.id = 1 and
// (
// p.displayName like '%rimadyl%'
// or p.manufacturer.name like '%rimadyl%'
// or p.description like '%rimadyl%'
// or p.longdescription like '%rimadyl%'
// or p.longdescription2 like '%rimadyl%'
// or p.manufacturerPartNumber like '%rimadyl%'
// or p.partNumber like '%rimadyl%'
// )
@Test
public void testRelationshipWhereClause() throws Exception {
Artist a = context.newObject(Artist.class);
a.setArtistName("a");
Painting p = context.newObject(Painting.class);
p.setPaintingTitle("p");
p.setToArtist(a);
context.commitChanges();
EJBQLQuery query = new EJBQLQuery("select p from Painting p where p.toArtist=:a");
query.setParameter("a", a);
List<Painting> paintings = context.performQuery(query);
assertEquals(1, paintings.size());
assertSame(p, paintings.get(0));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class MappedQueryIT method testSQLTemplateUpdate.
@Test
public void testSQLTemplateUpdate() throws Exception {
int updated = MappedExec.query("NonSelectingQuery").update(context)[0];
assertEquals(1, updated);
Painting painting = ObjectSelect.query(Painting.class).selectOne(context);
assertEquals("No Painting Like This", painting.getPaintingTitle());
assertEquals(12.5, painting.getEstimatedPrice().doubleValue(), 0);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class OrderingTest method testCompare3.
@Test
public void testCompare3() {
Painting p1 = new Painting();
p1.setEstimatedPrice(new BigDecimal(1000.00));
Painting p2 = new Painting();
p2.setEstimatedPrice(new BigDecimal(2000.00));
Painting p3 = new Painting();
p3.setEstimatedPrice(new BigDecimal(2000.00));
Ordering ordering = new Ordering("estimatedPrice", SortOrder.ASCENDING);
assertTrue(ordering.compare(p1, p2) < 0);
assertTrue(ordering.compare(p2, p1) > 0);
assertTrue(ordering.compare(p2, p3) == 0);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereBetween.
@Test
public void testSelectFromWhereBetween() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P WHERE p.estimatedPrice BETWEEN 2000 AND 3500";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
Painting p = (Painting) ps.get(0);
assertEquals("P1", p.getPaintingTitle());
assertEquals(3000d, p.getEstimatedPrice().doubleValue(), 0.00001);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereAndEqual.
@Test
public void testSelectFromWhereAndEqual() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P where P.paintingTitle = 'P1' " + "AND p.estimatedPrice = 3000";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
Painting p = (Painting) ps.get(0);
assertEquals("P1", p.getPaintingTitle());
assertEquals(3000d, p.getEstimatedPrice().doubleValue(), 0.00001);
}
Aggregations