Hi,
I worked on a small project in order to discover how things work for
couchbase-lite-java-1.2.0 on
Windows 10.
For this project I created a view and then put an object which was not an
instance of String as a key of the mapper here is the code snippet :
public void createEventsByDateView() {
View eventsByDateView = this.getView("eventsByDate");
if (eventsByDateView != null) {
eventsByDateView.setMap(
new Mapper(){
public void map(Map<String, Object> document,
Emitter emitter) {
if(document.get("location") != null){
emitter.emit(
new SimplePojo("location"),
document.get("location"));
}
else{
emitter.emit(new SimplePojo("mock"),
document.get("mock"));
}
}
}, "3"
);
}
printQueryToLog(eventsByDateView);
}
and here is the the SimplePojo :
private class SimplePojo{
SimplePojo(String string){
this.setString(string);
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
String string;
}
After running the app I've had this exception :
*Exception in thread "main" java.lang.Error: invalid class for JSON at
com.couchbase.cbforest.View.keyAdd(View.java:163) at
com.couchbase.cbforest.View.objectToKey(View.java:124) at
com.couchbase.cbforest.Indexer.emit(Indexer.java:33) at
com.couchbase.lite.store.ForestDBViewStore.emit(ForestDBViewStore.java:336)
at
com.couchbase.lite.store.ForestDBViewStore.updateIndexes(ForestDBViewStore.java:276)
at com.couchbase.lite.View.updateIndexes(View.java:321) at
com.couchbase.lite.View.updateIndex(View.java:294) at
com.couchbase.lite.Database.queryViewNamed(Database.java:2092) at
com.couchbase.lite.Query.run(Query.java:433) at
Client.printQueryToLog(Client.java:285) at
Client.createEventsByDateView(Client.java:261) at
Client.helloCBL(Client.java:73) at Client.run(Client.java:38) at
StartApp.main(StartApp.java:6) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:144*
Must I use only use String as the key of the mapper on Windows ?
Alex
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/9a131662-4734-44b0-9905-1bd979f587f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.