use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextEJBQLFunctionalExpressionsIT method testSIZE.
@Test
public void testSIZE() {
Artist a1 = context.newObject(Artist.class);
a1.setArtistName("a1");
Artist a2 = context.newObject(Artist.class);
a2.setArtistName("a2");
Painting p12 = context.newObject(Painting.class);
p12.setPaintingTitle("p12");
a2.addToPaintingArray(p12);
Painting p22 = context.newObject(Painting.class);
p22.setPaintingTitle("p22");
a2.addToPaintingArray(p22);
context.commitChanges();
// this fails:
// EJBQLQuery query = new EJBQLQuery(
// "SELECT d FROM Artist d WHERE SIZE(d.paintingArray) = 2");
// List<?> objects = context.performQuery(query);
// assertEquals(1, objects.size());
// assertTrue(objects.contains(a2));
//
// EJBQLQuery query2 = new EJBQLQuery(
// "SELECT d FROM Artist d WHERE SIZE(d.paintingArray) = 0");
// List<?> objects2 = context.performQuery(query2);
// assertEquals(1, objects2.size());
// assertTrue(objects2.contains(a1));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReadToOneRel3.
@Test
public void testReadToOneRel3() throws Exception {
createArtistWithPaintingDataSet();
Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
Gallery g1 = p1.getToGallery();
assertNull(g1);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReadToOneRel1.
@Test
public void testReadToOneRel1() throws Exception {
createArtistWithPaintingDataSet();
Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
Artist a1 = p1.getToArtist();
assertNotNull(a1);
assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
assertEquals("aX", a1.getArtistName());
assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReciprocalRel1.
@Test
public void testReciprocalRel1() throws Exception {
createArtistWithPaintingDataSet();
Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
Artist a1 = p1.getToArtist();
assertNotNull(a1);
assertEquals("aX", a1.getArtistName());
List<Painting> paintings = a1.getPaintingArray();
assertEquals(1, paintings.size());
Painting p2 = paintings.get(0);
assertSame(p1, p2);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReadToManyRel2.
@Test
public void testReadToManyRel2() throws Exception {
// test empty relationship
tArtist.insert(11, "aX");
Artist a1 = Cayenne.objectForPK(context, Artist.class, 11);
List<Painting> plist = a1.getPaintingArray();
assertNotNull(plist);
assertEquals(0, plist.size());
}
Aggregations