protected void createArtistWithTwoPaintingsAndTwoInfosDataSet() throws Exception { tArtist.insert(11, "artist2"); tPainting.insert(6, "p_artist2", 11, 1000); tPainting.insert(7, "p_artist3", 11, 2000); tPaintingInfo.insert(6, "xYs"); }
private void createTwoArtistsTwoPaintingsDataSet() throws Exception { tArtist.insert(1, "AA"); tArtist.insert(2, "BB"); tPainting.insert(1, 1, "X"); tPainting.insert(2, 2, "Y"); }
protected void creatArtistsDataSet() throws Exception { tArtist.insert(33001, "c"); tArtist.insert(33002, "b"); tArtist.insert(33003, "f"); tArtist.insert(33004, "d"); tArtist.insert(33005, "a"); tArtist.insert(33006, "e"); }
protected void createDistinctClobFetchWithToManyJoin() throws Exception { tClobMaster.insert(1, "cm1 clob", "cm1"); tClobMaster.insert(2, "cm2 clob", "cm2"); tClobMaster.insert(3, "cm3 clob", "cm3"); tClobDetail.insert(1, 1, "cd11"); tClobDetail.insert(2, 2, "cd21"); tClobDetail.insert(3, 2, "cd22"); tClobDetail.insert(4, 3, "cd31"); }
@Test public void testPrefetch() throws Exception { createTwoArtists(); tPainting.insert(45, 3, "One"); tPainting.insert(48, 3, "Two"); final Artist a3 = SelectById.query(Artist.class, 3) .prefetch(Artist.PAINTING_ARRAY.joint()) .selectOne(context); interceptor.runWithQueriesBlocked( new UnitTestClosure() { @Override public void execute() { assertNotNull(a3); assertEquals("artist3", a3.getArtistName()); assertEquals(2, a3.getPaintingArray().size()); a3.getPaintingArray().get(0).getPaintingTitle(); a3.getPaintingArray().get(1).getPaintingTitle(); } }); }
public void testLocalObject_SameContext() throws Exception { tArtist.insert(456, "Bla"); final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456); interceptor.runWithQueriesBlocked( new UnitTestClosure() { public void execute() { Artist a2 = context1.localObject(a1); assertSame(a2, a1); } }); }
protected void createTwoArtistsWithExhibitsDataSet() throws Exception { tArtist.insert(11, "artist2"); tArtist.insert(101, "artist3"); tGallery.insert(25, "gallery1"); tGallery.insert(31, "gallery2"); tGallery.insert(45, "gallery3"); Timestamp now = new Timestamp(System.currentTimeMillis()); tExhibit.insert(1, 25, now, now); tExhibit.insert(2, 31, now, now); tExhibit.insert(3, 45, now, now); tExhibit.insert(4, 25, now, now); tArtistExhibit.insert(11, 2); tArtistExhibit.insert(11, 4); tArtistExhibit.insert(101, 1); tArtistExhibit.insert(101, 3); tArtistExhibit.insert(101, 4); }
public void testLocalObject_NotInCache() throws Exception { tArtist.insert(456, "Bla"); final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456); interceptor.runWithQueriesBlocked( new UnitTestClosure() { public void execute() { Artist a3 = context2.localObject(a1); assertNotSame(a3, a1); assertEquals(a3.getObjectId(), a1.getObjectId()); assertSame(context2, a3.getObjectContext()); } }); }
public void testPrefetchingToOneNull() throws Exception { tPainting.insert(6, "p_Xty", null, 1000); SelectQuery q = new SelectQuery(Painting.class); q.addPrefetch(Painting.TO_ARTIST_PROPERTY); final List<Painting> paintings = context.performQuery(q); queryInterceptor.runWithQueriesBlocked( new UnitTestClosure() { public void execute() { assertEquals(1, paintings.size()); Painting p2 = paintings.get(0); assertNull(p2.readProperty(Painting.TO_ARTIST_PROPERTY)); } }); }
public void testLocalObject_FFE_InvalidID() throws Exception { tArtist.insert(777, "AA"); final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 777); Artist a3 = context2.localObject(a1); assertEquals(PersistenceState.HOLLOW, a3.getPersistenceState()); context1.invalidateObjects(a1); tArtist.deleteAll(); assertEquals(PersistenceState.HOLLOW, a3.getPersistenceState()); try { a3.getArtistName(); fail( "FaultFailureException wasn't thrown on attempt to " + "resolve HOLLOW object with no backing DB row"); } catch (FaultFailureException e) { // expected } }
protected void createDistinctClobFetchDataSet() throws Exception { tClobMaster.insert(1, "cm1 clob", "cm1"); tClobMaster.insert(2, "cm2 clob", "cm2"); tClobMaster.insert(3, "cm3 clob", "cm3"); }
private void createTwoArtistsThreePaintingsDataSet() throws Exception { createTwoArtistsTwoPaintingsDataSet(); tPainting.insert(3, 2, "X"); }
protected void createSingleArtistDataSet() throws Exception { tArtist.insert(33001, "aaa"); }
private void createTwoArtistsTwoPaintings() throws Exception { tArtist.insert(33001, "A"); tArtist.insert(33002, "B"); tPainting.insert(33005, 33001, "C", 500); tPainting.insert(33006, 33002, "C", 500); }
private void createFourPaintings() throws Exception { tPainting.insert(33001, null, "A", 3000); tPainting.insert(33002, null, "B", 2000); tPainting.insert(33003, null, "C", 1000); tPainting.insert(33004, null, "C", 500); }
protected void createTwoArtistsAndTwoPaintingsDataSet() throws Exception { tArtist.insert(11, "artist2"); tArtist.insert(101, "artist3"); tPainting.insert(6, "p_artist3", 101, 1000); tPainting.insert(7, "p_artist2", 11, 2000); }
private void createTwoArtists() throws Exception { tArtist.insert(2, "artist2"); tArtist.insert(3, "artist3"); }
private void createOneArtistOnePaintingDataSet() throws Exception { tArtist.insert(1, "a1"); tPainting.insert(1, "p1", 1); }