@Test
  public void testRefreshingToOne() throws Exception {

    createOneArtistOnePaintingDataSet();

    Painting p = Cayenne.objectForPK(context, Painting.class, 1);

    // resolve artist once before running non-refreshing query, to check that we do
    // not refresh the object

    Artist a = Cayenne.objectForPK(context, Artist.class, 1);
    long v = a.getSnapshotVersion();
    int writeCalls = a.getPropertyWrittenDirectly();
    assertEquals("a1", a.getArtistName());

    assertEquals(1, tArtist.update().set("ARTIST_NAME", "a2").where("ARTIST_ID", 1).execute());

    RelationshipQuery toOne =
        new RelationshipQuery(p.getObjectId(), Painting.TO_ARTIST_PROPERTY, true);

    List<Artist> related = context.performQuery(toOne);
    assertEquals(1, related.size());
    assertTrue(related.contains(a));
    assertEquals("a2", a.getArtistName());
    assertTrue(
        "Looks like relationship query didn't cause a snapshot refresh",
        v < a.getSnapshotVersion());
    assertTrue(
        "Looks like relationship query didn't cause a snapshot refresh",
        writeCalls < a.getPropertyWrittenDirectly());
  }