Firebase Java Query.equalTo() does not work -
i trying understand how method works. have set , pushed strings root of firebase. made reference firebase , trying make query object way
query refq = ref.orderbyvalue().equalto(word);
where word same string pushed firebase.
i want print value console. weird thing happens console hangs in infinite loop , need force terminate. put print statement after above line of code , never gets reached.
so question is, doing wrong?
edit: forgot mention word
static , 1 of words pushed firebase. doing test functionality.
i created minimal sample , ran in jdk 1.8.0_31:
public static void main(string[] args) throws exception { firebase ref = new firebase("https://stackoverflow.firebaseio.com/29553461"); /* map<string,object> map = new hashmap<string, object>(); map.put("puf", "frank van puffelen"); map.put("frank", "frank van puffelen"); map.put("david", "david east"); map.put("east", "david east"); ref.setvalue(map); */ query refq = ref.orderbyvalue().equalto("frank van puffelen"); refq.addchildeventlistener(new childeventlistener() { @override public void onchildadded(datasnapshot datasnapshot, string s) { system.out.println("child added: "+datasnapshot.getkey()+": "+datasnapshot.getvalue()); } @override public void onchildchanged(datasnapshot datasnapshot, string s) { } @override public void onchildremoved(datasnapshot datasnapshot) { } @override public void onchildmoved(datasnapshot datasnapshot, string s) { } @override public void oncancelled(firebaseerror firebaseerror) { } }); console console = system.console(); if (console != null) { console.format("press enter process.\n"); console.readline(); } else { system.out.println("sleeping 5 seconds, in hopes done then."); thread.sleep(5000); } }
it prints out:
child added: frank: frank van puffelen child added: puf: frank van puffelen
so seems work fine me.