context.performGenericQuery(inserts);
Artist a1 = Cayenne.objectForPK(context, Artist.class, 1);
Artist a2 = Cayenne.objectForPK(context, Artist.class, 2);
EJBQLQuery query = new EJBQLQuery(
"SELECT a FROM Artist a WHERE TRIM(a.artistName) = 'A'");
List<?> objects = context.performQuery(query);
assertEquals(2, objects.size());
assertTrue(objects.contains(a1));
assertTrue(objects.contains(a2));
query = new EJBQLQuery(
"SELECT a FROM Artist a WHERE TRIM(LEADING FROM a.artistName) = 'A'");
objects = context.performQuery(query);
// this is fuzzy cause some DB trim trailing data by default
assertTrue(objects.size() == 1 || objects.size() == 2);
assertTrue(objects.contains(a1));
query = new EJBQLQuery(
"SELECT a FROM Artist a WHERE TRIM(TRAILING FROM a.artistName) = 'A'");
objects = context.performQuery(query);
assertEquals(1, objects.size());
assertTrue(objects.contains(a2));
query = new EJBQLQuery(
"SELECT a FROM Artist a WHERE TRIM(BOTH FROM a.artistName) = 'A'");
objects = context.performQuery(query);
assertEquals(2, objects.size());
assertTrue(objects.contains(a1));
assertTrue(objects.contains(a2));