@@ -83,6 +83,7 @@ public class Select {
8383 private String SQLString ;
8484 private Object typeObject ;
8585 private static final String KEY_FUNCTION_PARAMETER = "%column" ;
86+ private static final String KEY_COLIMN_NAME_MAX = "value_function" ;
8687 private String type ;
8788 /**
8889 * @param typeObject
@@ -101,7 +102,7 @@ public Select(Object typeObject, String type) {
101102 this .functionParameter = true ;
102103 break ;
103104 case "MAX" :
104- SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ")" ;
105+ SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ") INTO " + KEY_COLIMN_NAME_MAX ;
105106 this .functionParameter = true ;
106107 break ;
107108 case "MIN" :
@@ -261,13 +262,20 @@ public Object execute() {
261262 cursor .moveToFirst ();
262263 return cursor .getInt (0 );
263264 }else if (type .equals ("MAX" ) || type .equals ("MIN" )){
264- if (cursor .moveToFirst ()){
265- for (Field f :fields ){
266- Object object = checkItem (f , cursor );
267- if (object != null )
268- hashMap .put (f .getName (), object );
265+ if (cursor !=null ){
266+ cursor .moveToFirst ();
267+ while (!cursor .isAfterLast ()) {
268+ for (Field f : fields ) {
269+ Object object = checkItem (f , cursor );
270+ if (object != null )
271+ hashMap .put (f .getName (), object );
272+ }
273+ String hashJson = new Gson ().toJson (hashMap );
274+ lstClasses .add (new Gson ().fromJson (hashJson , (Type ) typeObject .getClass ()));
269275 }
270276 }
277+ cursor .close ();
278+ return lstClasses ;
271279 }
272280 while (cursor .moveToNext ()) {
273281 for (Field f : fields ) {
0 commit comments