thiagolocatelli / parse4j

Java Library to deal with Parse (parse.com) REST API
http://thiagolocatelli.github.io/parse4j
143 stars 117 forks source link

Query returns multiple times the same result #40

Open Emener opened 9 years ago

Emener commented 9 years ago

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.

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 :)