public GenericCrud(Object beanObj, String fromQuery, MyDatabase database) {
        this.database = database;
        this.beanObj = beanObj;
        this.fromQuery = fromQuery;

        //Check for annotations      
       
        if (tablesFields.containsKey(beanObj.getClass().getName())) {
            tableFields = tablesFields.get(beanObj.getClass().getName());
        } else {
            tableFields = new ArrayList<BeanTableMapping>();
            //System.out.println("\tAbout to parse annotations:"+beanObj.getClass());
            //We must access to the input class as well as all its possible subclasses
            Class<?> currentClass = beanObj.getClass();
            while(currentClass!=null)
            {
            String defaultTable = fromQuery;
            if (currentClass.isAnnotationPresent(DefaultTableMapping.class)) {
                DefaultTableMapping annotation = currentClass.getAnnotation(DefaultTableMapping.class);
                defaultTable = annotation.tableName();
             }
              
            for (Field field : currentClass.getDeclaredFields()) {
                //System.out.println("\t\t Found field:"+field.getName());
                if (field.isAnnotationPresent(TableMapping.class)) {
                    //System.out.println("\t\t Found field with annotation:"+field.getName());
                    TableMapping annotation = field.getAnnotation(TableMapping.class);
                    BeanTableMapping beanTableMapping = new BeanTableMapping();
                    String currentTableName = annotation.tableName();
                    if (currentTableName.isEmpty()) {
                        currentTableName = defaultTable;
                    }
                    String tableFieldName = annotation.tableField();
                    if (tableFieldName.isEmpty()) {
                        tableFieldName = field.getName();
                    }
                    beanTableMapping.setBeanFieldName(field.getName());
                    beanTableMapping.setTableFieldName(tableFieldName);
                    beanTableMapping.setTableName(currentTableName);
                    beanTableMapping.setReadable(annotation.mode().contains("r"));
                    beanTableMapping.setWritable(annotation.mode().contains("w"));
                    beanTableMapping.setHoldingClass(currentClass);
                    if(field.isAnnotationPresent(PK.class))
                    {
                        beanTableMapping.setPk(true);
                        beanTableMapping.setAutoincrement(field.getAnnotation(PK.class).autoIncrement());
                    }
                    tableFields.add(beanTableMapping);
                }
                 
                }
                currentClass = currentClass.getSuperclass();
            }

            tablesFields.put(beanObj.getClass().getName(), tableFields);
        }
        
        //System.out.println("instantiated genericcrud "+beanObj.getClass()+": "+tableFields.size());

    }