Preparation
Default mapper reads RS column and table names from RS meta-data and external maps, if provided. Since column name is always available in RS meta-data, it may be used to hold table name information. Column names may contain table code separator ( {@link jodd.db.oom.DbOomManager#getColumnAliasSeparator()} thatdivides column name to table reference and column name. Here, table reference may be either table name or table alias. When it is table alias, external alias-to-name map must be provided. Hence, this defines the table name, and there is no need to read it from RS meta-data.
When column name doesn't contain a separator, it may be either an actual column name, or a column code. For column codes, both table and column name is lookup-ed from external map. If column name is an actual column name, table information is read from the RS meta data. Unfortunately, some DBs (such Oracle) doesn't implements this simple JDBC feature. Therefore, it must be expected that column table name is not available.
Table name is also not available for columns which are not directly table columns: e.g. some calculations, counts etc.
Parsing
Parser takes types array and tries to populate their instances in best possible way. It assumes that provided types list matches selected columns. That is very important, and yet very easy and natural to follow. So, parser will try to inject columns value into the one result instance. Now, there are two types of instances: simple types (numbers and strings) and entities (pojo objects). Simple types are always mapped to one and only one column. Entities will be mapped to all possible columns that can be matched starting from current column. So, simple types are not column-hungry, entity types are column-hungry:)
A column can be injected in one entities property only once. If one column is already mapped to current result, RS mapper will assume that current result is finished with mapping and will proceed to the next one. Similarly, if property name is not found for a column, RS mapper will proceed to the next result. Therefore, entity types are column precise and hungry;) - all listed columns must be mapped somewhere.
Results that are not used during parsing will be set to null
.
|
|