use of org.apache.cayenne.Fault in project cayenne by apache.
the class ObjectDiff method getArcSnapshotValue.
ObjectId getArcSnapshotValue(String propertyName) {
Object value = arcSnapshot != null ? arcSnapshot.get(propertyName) : null;
if (value instanceof Fault) {
Persistent target = (Persistent) ((Fault) value).resolveFault(object, propertyName);
value = target != null ? target.getObjectId() : null;
arcSnapshot.put(propertyName, value);
}
return (ObjectId) value;
}
use of org.apache.cayenne.Fault in project cayenne by apache.
the class FlattenedRelationshipInContextIT method testIsToOneTargetModifiedFlattenedFault1.
@Test
public void testIsToOneTargetModifiedFlattenedFault1() throws Exception {
createFlattenedTestDataSet();
// fetch
List<?> ft3s = context.performQuery(new SelectQuery(FlattenedTest3.class));
assertEquals(1, ft3s.size());
FlattenedTest3 ft3 = (FlattenedTest3) ft3s.get(0);
// mark as dirty for the purpose of the test...
ft3.setPersistenceState(PersistenceState.MODIFIED);
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
// test that checking for modifications does not trigger a fault, and generally
// works well
ClassDescriptor d = context.getEntityResolver().getClassDescriptor("FlattenedTest3");
ArcProperty flattenedRel = (ArcProperty) d.getProperty("toFT1");
ObjectDiff diff = context.getObjectStore().registerDiff(ft3.getObjectId(), null);
assertFalse(DataRowUtils.isToOneTargetModified(flattenedRel, ft3, diff));
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
}
use of org.apache.cayenne.Fault in project cayenne by apache.
the class ColumnSelectIT method testObjectWithDisjointByIdPrefetch.
@Test
public void testObjectWithDisjointByIdPrefetch() {
List<Artist> result = ObjectSelect.query(Artist.class).column(Property.createSelf(Artist.class)).prefetch(Artist.PAINTING_ARRAY.disjointById()).select(context);
assertEquals(20, result.size());
for (Artist artist : result) {
assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
Object paintingsArr = artist.readPropertyDirectly(Artist.PAINTING_ARRAY.getName());
assertFalse(paintingsArr instanceof Fault);
}
}
use of org.apache.cayenne.Fault in project cayenne by apache.
the class ColumnSelectIT method checkAggregatePrefetchResults.
private void checkAggregatePrefetchResults(List<Object[]> result) {
assertEquals(5, result.size());
for (Object[] next : result) {
assertTrue(next[0] instanceof Artist);
assertTrue(next[1] instanceof Long);
Artist artist = (Artist) next[0];
assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
Object paintingsArr = artist.readPropertyDirectly(Artist.PAINTING_ARRAY.getName());
assertFalse(paintingsArr instanceof Fault);
assertTrue(((List) paintingsArr).size() == (long) next[1]);
}
}
use of org.apache.cayenne.Fault in project cayenne by apache.
the class ColumnSelectIT method checkPrefetchResults.
private void checkPrefetchResults(List<Object[]> result) {
assertEquals(21, result.size());
for (Object[] next : result) {
assertTrue(next[0] instanceof Artist);
assertTrue(next[1] instanceof java.util.Date);
assertTrue(next[2] instanceof String);
Artist artist = (Artist) next[0];
assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
Object paintingsArr = artist.readPropertyDirectly(Artist.PAINTING_ARRAY.getName());
assertFalse(paintingsArr instanceof Fault);
assertTrue(((List) paintingsArr).size() > 0);
}
}
Aggregations