0

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.

kingspeech
  • 1,776
  • 2
  • 14
  • 24
Emener
  • 1
  • 3
  • Find the produced query and run it yourself against the database. Check if that also results in 5 times the same result. Because as far as your code shows, there's no real coding error (except that the assignments to `themeTemp` look strange and make no sense). – ChristopherS Apr 27 '15 at 10:22
  • Dear Emener; Can you provide the snapshot of your Parse Table? – kingspeech Apr 27 '15 at 10:29
  • Kingspeech, I've edited the post to add a crop of the Parse Table I'm using. – Emener Apr 27 '15 at 10:42
  • @ChristopherS : I'll add the query on IOS as an edit, can't format here =) – Emener Apr 27 '15 at 10:45

0 Answers0