Skip to main content

A Short Note About Properties And Politics

Posted by evanx on July 7, 2007 at 9:13 AM PDT

Another reason why we need properties in the language is ... for "native" database queries, e.g.

Person person = createQuery(new WhereLikePredicate(, "Homer Simpson"));

where is a property, ie. Person.class has an accessor getName().

In this case, our JPA queries are refactorable, yippee! If you have a real query, it's more obvious (no offense), eg.

      SelectQuery query = createSelectQuery();
      query.setTitle("Fido's in region %s", regionId);
      query.selectExclude(dog.address);, organisation.organisationName);
      query.join(dog, organisation, region);
      query.whereEquals(region.regionId, regionId);
      query.whereStartsWithIgnoreCase(dog.dogName, "fido");
      query.whereIs(, true);
      query.orderBy(organisation.organisationId, dog.dogName);

as presented in the The SQL precursor to the Jelly Bean series.

Having JPA queries in strings (and any references in strings) is something that i hope people cannot tolerate going forward!? ;)