本文整理汇总了Java中org.apache.ibatis.mapping.ResultMap.getResultMappings方法的典型用法代码示例。如果您正苦于以下问题:Java ResultMap.getResultMappings方法的具体用法?Java ResultMap.getResultMappings怎么用?Java ResultMap.getResultMappings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.mapping.ResultMap
的用法示例。
在下文中一共展示了ResultMap.getResultMappings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPrimitiveResultObject
import org.apache.ibatis.mapping.ResultMap; //导入方法依赖的package包/类
private Object createPrimitiveResultObject(ResultSetWrapper rsw, ResultMap resultMap, String columnPrefix) throws SQLException {
final Class<?> resultType = resultMap.getType();
final String columnName;
if (!resultMap.getResultMappings().isEmpty()) {
final List<ResultMapping> resultMappingList = resultMap.getResultMappings();
final ResultMapping mapping = resultMappingList.get(0);
columnName = prependPrefix(mapping.getColumn(), columnPrefix);
} else {
columnName = rsw.getColumnNames().get(0);
}
final TypeHandler<?> typeHandler = rsw.getTypeHandler(resultType, columnName);
return typeHandler.getResult(rsw.getResultSet(), columnName);
}
示例2: createMeta
import org.apache.ibatis.mapping.ResultMap; //导入方法依赖的package包/类
protected RDBTableMetaData createMeta(String tableName, String resultMapId) {
RDBDatabaseMetaData active = getActiveDatabase();
String cacheKey = tableName.concat("-").concat(resultMapId);
Map<String, RDBTableMetaData> cache = metaCache.get(active);
RDBTableMetaData cached = cache.get(cacheKey);
if (cached != null) {
return cached;
}
RDBTableMetaData rdbTableMetaData = new RDBTableMetaData();
ResultMap resultMaps = ResultMapsUtils.getResultMap(resultMapId);
rdbTableMetaData.setName(tableName);
rdbTableMetaData.setDatabaseMetaData(active);
List<ResultMapping> resultMappings = new ArrayList<>(resultMaps.getResultMappings());
resultMappings.addAll(resultMaps.getIdResultMappings());
resultMappings.forEach(resultMapping -> {
if (resultMapping.getNestedQueryId() == null) {
RDBColumnMetaData column = new RDBColumnMetaData() {
@Override
public RDBColumnMetaData clone() {
RDBColumnMetaData target = super.clone();
target.setValueConverter(getValueConverter());
return target;
}
};
column.setJdbcType(JDBCType.valueOf(resultMapping.getJdbcType().name()));
column.setName(resultMapping.getColumn());
if (!StringUtils.isNullOrEmpty(resultMapping.getProperty())) {
column.setAlias(resultMapping.getProperty());
}
column.setJavaType(resultMapping.getJavaType());
column.setProperty("resultMapping", resultMapping);
ValueConverter dateConvert = new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()) {
@Override
public Object getData(Object value) {
if (value instanceof Number) {
return new Date(((Number) value).longValue());
}
return super.getData(value);
}
};
if (column.getJdbcType() == JDBCType.DATE) {
column.setValueConverter(dateConvert);
} else if (column.getJdbcType() == JDBCType.TIMESTAMP) {
column.setValueConverter(dateConvert);
} else if (column.getJdbcType() == JDBCType.NUMERIC) {
column.setValueConverter(new NumberValueConverter(column.getJavaType()));
}
rdbTableMetaData.addColumn(column);
}
});
cache.put(cacheKey, rdbTableMetaData);
if (useJpa) {
Class type = entityFactory.getInstanceType(resultMaps.getType());
RDBTableMetaData parseResult = JpaAnnotationParser.parseMetaDataFromEntity(type);
if (parseResult != null) {
for (RDBColumnMetaData columnMetaData : parseResult.getColumns()) {
if (rdbTableMetaData.findColumn(columnMetaData.getName()) == null) {
columnMetaData = columnMetaData.clone();
columnMetaData.setProperty("fromJpa", true);
rdbTableMetaData.addColumn(columnMetaData);
}
}
}
}
return rdbTableMetaData;
}