@@ -49,6 +49,7 @@ public abstract class Model {
49
49
private final TableInfo mTableInfo ;
50
50
private final String idName ;
51
51
private static Map <String , List <Integer >> columnIndexesCache = new HashMap <String , List <Integer >>();
52
+ private static Map <String , List <Class >> fieldTypesCache = new HashMap <String , List <Class >>();
52
53
53
54
//////////////////////////////////////////////////////////////////////////////////////
54
55
// CONSTRUCTORS
@@ -194,17 +195,25 @@ public final void loadFromCursor(Cursor cursor) {
194
195
columnIndexes = new ArrayList <Integer >();
195
196
columnIndexesCache .put (mTableInfo .getTableName (), columnIndexes );
196
197
}
198
+ List <Class > fieldTypes = fieldTypesCache .get (mTableInfo .getTableName ());
199
+ if (fieldTypes == null ) {
200
+ fieldTypes = new ArrayList <Class >();
201
+ fieldTypesCache .put (mTableInfo .getTableName (), fieldTypes );
202
+ }
197
203
int counter = 0 ;
198
204
for (Field field : mTableInfo .getFields ()) {
199
- Class <?> fieldType = field .getType ();
200
-
201
205
final int columnIndex ;
206
+ Class <?> fieldType ;
202
207
if (columnIndexes .size () <= counter ) {
203
208
String fieldName = mTableInfo .getColumnName (field );
204
209
columnIndex = columnsOrdered .indexOf (fieldName );
205
210
columnIndexes .add (columnIndex );
211
+
212
+ fieldType = field .getType ();
213
+ fieldTypes .add (fieldType );
206
214
} else {
207
215
columnIndex = columnIndexes .get (counter );
216
+ fieldType = fieldTypes .get (counter );
208
217
}
209
218
210
219
if (columnIndex < 0 ) {
0 commit comments