use of org.dbflute.s2dao.rowcreator.TnRelationKey in project dbflute-core by dbflute.
the class TnBeanListResultSetHandler method mappingFirstRelation.
/**
* Do mapping first relation row. <br>
* This logic is similar to next relation mapping in {@link TnRelationRowCreatorExtension}. <br>
* So you should check it when this logic has modification.
* @param rs The result set of JDBC, connecting to database here. (NotNull)
* @param row The base point row. (NotNull)
* @param rpt The property type of the relation. (NotNull)
* @param selectColumnMap The map of select column. (NotNull)
* @param selectIndexMap The map of select index. map:{entityNo(e.g. loc00 or _0_3) = map:{selectColumnKeyName = selectIndex}} (NullAllowed)
* @param relPropCache The map of relation property cache. (NotNull)
* @param relRowCache The cache of relation row. (NotNull)
* @param relSelector The selector of relation, which can determines e.g. is it not-selected relation?. (NotNull)
* @throws SQLException When it fails to handle the SQL.
*/
protected void mappingFirstRelation(ResultSet rs, Object row, TnRelationPropertyType rpt, Map<String, String> selectColumnMap, Map<String, Map<String, Integer>> selectIndexMap, Map<String, Map<String, TnPropertyMapping>> relPropCache, TnRelationRowCache relRowCache, TnRelationSelector relSelector) throws SQLException {
final String relationNoSuffix = getFirstLevelRelationPath(rpt);
final TnRelationKey relKey = // basic resource
relRowCache.createRelationKey(// basic resource
rs, // basic resource
rpt, // select resource
selectColumnMap, // select resource
selectIndexMap, // indicates relation location
relationNoSuffix);
Object relationRow = null;
if (relKey != null) {
final boolean canUseRelationCache = relSelector.canUseRelationCache(relationNoSuffix);
if (canUseRelationCache) {
relationRow = relRowCache.getRelationRow(relationNoSuffix, relKey);
}
if (relationRow == null) {
// when no cache
relationRow = createRelationRow(// basic resource
rs, // basic resource
rpt, // select resource
selectColumnMap, // select resource
selectIndexMap, relKey, relPropCache, relRowCache, // relation resource
relSelector);
if (relationRow != null) {
// is new created relation row
adjustCreatedRelationRow(relationRow, relationNoSuffix, relSelector, rpt);
if (canUseRelationCache) {
relRowCache.addRelationRow(relationNoSuffix, relKey, relationRow);
}
}
}
}
// if exists, optional or plain value
// if null, empty optional or nothing
relationRow = filterOptionalRelationRowIfNeeds(row, rpt, relationRow);
if (relationRow != null) {
// exists or empty optional
rpt.getPropertyAccessor().setValue(row, relationRow);
}
}
use of org.dbflute.s2dao.rowcreator.TnRelationKey in project dbflute-core by dbflute.
the class TnRelationRowCreatorExtension method mappingNextRelation.
/**
* Do mapping next relation row. <br>
* This logic is similar to first relation mapping in {@link TnBeanListResultSetHandler}. <br>
* So you should check it when this logic has modification.
* @param res The resource of relation row creation. (NotNull)
* @param row The base point row, which is previous relation row. (NotNull)
* @throws SQLException When it fails to handle the SQL.
*/
protected void mappingNextRelation(TnRelationRowCreationResource res, Object row) throws SQLException {
if (res.isStopCurrentRelationMapping()) {
return;
}
// also saves it in resource
final TnRelationKey relKey = res.prepareRelationKey();
final TnRelationPropertyType rpt = res.getRelationPropertyType();
Object relationRow = null;
if (relKey != null) {
final String relationNoSuffix = res.getRelationNoSuffix();
final boolean canUseRelationCache = res.canUseRelationCache();
TnRelationRowCache relRowCache = null;
if (canUseRelationCache) {
relRowCache = res.getRelRowCache();
relationRow = relRowCache.getRelationRow(relationNoSuffix, relKey);
}
if (relationRow == null) {
// when no cache
relationRow = createRelationRow(res);
if (relationRow != null) {
// is new created relation row
adjustCreatedRelationRow(relationRow, res.getRelationNoSuffix(), res.getRelationSelector(), rpt);
if (canUseRelationCache) {
relRowCache.addRelationRow(relationNoSuffix, relKey, relationRow);
}
}
}
}
// if exists, optional or plain value
// if null, empty optional or nothing
relationRow = filterOptionalRelationRowIfNeeds(row, rpt, relationRow);
if (relationRow != null) {
// exists or empty optional
rpt.getPropertyAccessor().setValue(row, relationRow);
}
}
Aggregations