* </p>
*/
private SqlTree buildSqlTree(BeanDescriptor<?> desc){
SqlTree sqlTree = new SqlTree();
sqlTree.setSummary(desc.getName());
LinkedHashSet<String> includedProps = new LinkedHashSet<String>();
SqlTreeProperties selectProps = new SqlTreeProperties();
for (int i = 0; i < selectColumns.length; i++) {
DRawSqlColumnInfo columnInfo = selectColumns[i];
String propName = columnInfo.getPropertyName();
BeanProperty beanProperty = desc.getBeanProperty(propName);
if (beanProperty != null) {
if (beanProperty.isId()){
if (i > 0){
String m = "With "+desc+" query:"+name+" the ID is not the first column in the select. It must be...";
throw new PersistenceException(m);
} else {
withId = true;
}
} else {
includedProps.add(beanProperty.getName());
selectProps.add(beanProperty);
}
} else {
String m = "Mapping for " + desc.getFullName();
m += " query["+name+"] column[" + columnInfo + "] index[" + i;
m += "] not matched to bean property?";
logger.error(m);
}
}
SqlTreeNode sqlRoot = new SqlTreeNodeRoot(desc, selectProps, null, withId);
sqlTree.setRootNode(sqlRoot);
return sqlTree;
}