DbOomQuery
extends DbQuery
by adding methods for mapping result sets to objects.DbOomQuery
will 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 DbOomQuery
is 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.DbOomQuery
is not aware of relationships, boy
instance would be not injected into the girl
. Here this is done manually (line #5).find()
returns an Object
and not Object
array. The following example has no casting at all:DbOomQuery
has also methods for retrieving all records from the result set. They are returned as list or set of object arrays.iterate()
method.@DbTable
and @DbColumn
:@DbTable
and @DbColumn
just define table (or view) and column names. Think of @DbTable
like a set of ResultSet columns that applies to one bean.DbOomQuery
by 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: Girl
and Boy
instances. In order to put Girl
instance into a Boy
, user has to do that manually in the code.DbOomQuery
offers 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:Girl
and Boy
. Using provided hints, we define that Girl
instances should be injected into the Boy
instances, for every row. Here, Boy
entity instance is named as boy
. Girl
entity instance is named as boy.girl
, indicating that Girl
instance should be injected into the boy.girl
property.