use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereLess.
@Test
public void testSelectFromWhereLess() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P WHERE p.estimatedPrice < 5000";
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 testSelectFromWhereMatchRelationshipAndScalar.
@Test
public void testSelectFromWhereMatchRelationshipAndScalar() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P WHERE p.toArtist = 33002";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
Painting p = (Painting) ps.get(0);
assertEquals(33002, Cayenne.intPKForObject(p));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextExtrasIT method testPhantomRelationshipModificationValidate.
@Test
public void testPhantomRelationshipModificationValidate() throws Exception {
createPhantomRelationshipModificationCommitDataSet();
List<Painting> objects = ObjectSelect.query(Painting.class).select(context);
assertEquals(1, objects.size());
Painting p1 = objects.get(0);
Artist oldArtist = p1.getToArtist();
Artist newArtist = Cayenne.objectForPK(context, Artist.class, 33002);
assertNotSame(oldArtist, newArtist);
p1.setToArtist(newArtist);
p1.setToArtist(oldArtist);
p1.resetValidationFlags();
context.commitChanges();
assertFalse(p1.isValidateForSaveCalled());
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextExtrasIT method testPhantomRelationshipModificationCommit.
@Test
public void testPhantomRelationshipModificationCommit() throws Exception {
createPhantomRelationshipModificationCommitDataSet();
List<Painting> objects = ObjectSelect.query(Painting.class).select(context);
assertEquals(1, objects.size());
Painting p1 = objects.get(0);
Artist oldArtist = p1.getToArtist();
Artist newArtist = Cayenne.objectForPK(context, Artist.class, 33002);
assertNotSame(oldArtist, newArtist);
p1.setToArtist(newArtist);
p1.setToArtist(oldArtist);
context.commitChanges();
assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, oldArtist.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, newArtist.getPersistenceState());
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextExtrasIT method testPhantomModificationsValidateToOne.
@Test
public void testPhantomModificationsValidateToOne() throws Exception {
createPhantomModificationsValidateToOneDataSet();
List<Painting> objects = ObjectSelect.query(Painting.class).select(context);
Painting p1 = objects.get(0);
p1.setPaintingTitle(p1.getPaintingTitle());
p1.resetValidationFlags();
context.commitChanges();
assertFalse("To-one relationship presence caused incorrect validation call.", p1.isValidateForSaveCalled());
}
Aggregations