DbQueryby adding methods for mapping result sets to objects.
DbOomQuerywill try to map result set columns to objects as best as possible. Second way is by using annotations on domain objects, i.e. explicit markup, where no specific naming convention has to be followed. It is possible to mix both and perform mappings in both ways. Anyhow usage of
DbOomQueryis absolutely identical in both cases.
DbOomQuery.find()is used to find single set of objects from database, i.e. to find exactly one row and to map it to some set of objects.
DbOomQueryis not aware of relationships,
boyinstance would be not injected into the
girl. Here this is done manually (line #5).
Objectarray. The following example has no casting at all:
DbOomQueryhas also methods for retrieving all records from the result set. They are returned as list or set of object arrays.
@DbColumnjust define table (or view) and column names. Think of
@DbTablelike a set of ResultSet columns that applies to one bean.
DbOomQueryby default maps the result into the array of objects that are not connected anyhow. For example, the query
"select * from GIRL join BOY..."will return for each row an array of two elements:
Boyinstances. In order to put
Girlinstance into a
Boy, user has to do that manually in the code.
DbOomQueryoffers a simple way how to join resulting instances. To specify what to join, user has to provide so-called join hints. Join hint is a simple name of entities and their properties in the context of the query. Here is an example:
Boy. Using provided hints, we define that
Girlinstances should be injected into the
Boyinstances, for every row. Here,
Boyentity instance is named as
Girlentity instance is named as
boy.girl, indicating that
Girlinstance should be injected into the