|
89 | 89 | import net.sf.ehcache.Cache; |
90 | 90 | import net.sf.ehcache.CacheManager; |
91 | 91 | import net.sf.ehcache.Element; |
| 92 | +import org.springframework.util.ClassUtils; |
92 | 93 |
|
93 | 94 | /** |
94 | 95 | * GenericDaoBase is a simple way to implement DAOs. It DOES NOT |
@@ -2047,16 +2048,23 @@ public boolean unremove(ID id) { |
2047 | 2048 |
|
2048 | 2049 | @DB() |
2049 | 2050 | protected void setField(final Object entity, final ResultSet rs, ResultSetMetaData meta, final int index) throws SQLException { |
2050 | | - Attribute attr = _allColumns.get(new Pair<String, String>(meta.getTableName(index), meta.getColumnName(index))); |
| 2051 | + String tableName = meta.getTableName(index); |
| 2052 | + String columnName = meta.getColumnName(index); |
| 2053 | + Attribute attr = _allColumns.get(new Pair<>(tableName, columnName)); |
2051 | 2054 | if (attr == null) { |
2052 | 2055 | // work around for mysql bug to return original table name instead of view name in db view case |
2053 | 2056 | Table tbl = entity.getClass().getSuperclass().getAnnotation(Table.class); |
2054 | 2057 | if (tbl != null) { |
2055 | | - attr = _allColumns.get(new Pair<String, String>(tbl.name(), meta.getColumnLabel(index))); |
| 2058 | + attr = _allColumns.get(new Pair<>(tbl.name(), meta.getColumnLabel(index))); |
2056 | 2059 | } |
2057 | 2060 | } |
2058 | | - assert (attr != null) : "How come I can't find " + meta.getCatalogName(index) + "." + meta.getColumnName(index); |
2059 | | - setField(entity, attr.field, rs, index); |
| 2061 | + assert (attr != null) : "How come I can't find " + tableName + "." + columnName; |
| 2062 | + if(attr == null) { |
| 2063 | + logger.warn(String.format("Failed to find attribute in the entity %s to map column %s.%s (%s)", |
| 2064 | + ClassUtils.getUserClass(entity).getSimpleName(), tableName, columnName)); |
| 2065 | + } else { |
| 2066 | + setField(entity, attr.field, rs, index); |
| 2067 | + } |
2060 | 2068 | } |
2061 | 2069 |
|
2062 | 2070 | @Override |
|
0 commit comments