It was shown before how to persist new objects. Cayenne queries are used to access already saved objects. The primary query type used for selecting objects is SelectQuery. It can be mapped in CayenneModeler similar to how the SQLTemplate was mapped, in this chapter however we'll show how to create it using Cayenne API.
We don't have too much data in the database yet, but we can still demonstrate the main principles:
- Select all paintings (the code, and the log output it generates):
- Select paintings that start with "gi", ignoring case (read more about qualifier Expressions and ExpressionFactory here:
- Select all paintings done by artists who were born more than a 100 years ago (demonstrating using Expression.fromString(..) instead of ExpressionFactory):
Next Step: Tutorial Delete