Query returning multiple times the same result - Parse4J

139 Views Asked by At

As a preface, I'll apologize : I'm french, so there are French words in my queries and my tables.

Anyways, I've been having problem with the queries frome Parse4J (which is using the base model of the Android API from Parse.com).

In my data on Parse.com, I have Themes and SubThemes in the same table, but Themes have as RootTheme "Root", while SubThemes have as RootTheme another Theme.

I've been trying to add the results of a query into a ComboBox, but the Query has been returning me 5 times the same result, instead of the 5 RootThemes.

Here's my code :

private ParseQuery<ParseObject> themeQuery;
private ObservableList<String> themeComboData;

@Override
public void initialize(URL location, ResourceBundle resources) {
    themeComboData = FXCollections.observableArrayList();
    themeQuery = ParseQuery.getQuery("Theme").whereEqualTo("RootThemeID", "DBWw03ygSv");
    themeQuery.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> themeList, ParseException e) {
        if (e == null) {
            for(int i = 0; i < themeList.size(); i++){
                    ParseObject themeTemp;
                    themeTemp = new ParseObject("Theme");
                    themeTemp = themeList.get(i);
                    themeComboData.add(themeTemp.getString("Name"));
            }
        } else {
            Logger.getLogger(AmIApp.class.getName()).log(Level.SEVERE, null, e);
        }
        }
    });
    themeCombo.setItems(themeComboData);
}

But all it does is filling my Combo Box themeCombo with 5 times "Affinités", instead of the 5 different RootThemes.

Any advice ? Thanks in advance :)

Edit : Here's a crop of the Table I'm using :

https://i.stack.imgur.com/E0q6p.jpg

Edit : here is the query done with the ios

PFQuery * themeQuery = [PFQuery queryWithClassName:@"Theme"];
    [themeQuery whereKey:@"RootThemeID" equalTo:@"DBWw03ygSv"];
    [themeQuery findObjectsInBackgroundWithBlock:^(NSArray* themes, NSError* error) {
    if (!error) {
        for (PFObject *th in themes ) {
            NSLog(@"theme is : %@", th[@"Name"]);
        }
    }else {
        NSLog(@"Error: %@ %@", error, [error userInfo]);

    }
}];

It returns 5 different themes as expected, I’d like to do the same with Parse4J in java.

0

There are 0 best solutions below