Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
DBAccessException on .queryView()
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
matt martin  
View profile  
 More options Jul 26 2012, 12:45 am
From: matt martin <matt.m.u...@gmail.com>
Date: Wed, 25 Jul 2012 21:45:53 -0700 (PDT)
Local: Thurs, Jul 26 2012 12:45 am
Subject: DBAccessException on .queryView()

I am attempting to query an Ektorp view using the instructions on the wiki
but have been getting a DBAccessException. I've been scratching my head on
this one for about a week. My code and the stacktrace are below.

TDDatabase db = server.getDatabaseNamed(Global.YOURTEAM_DB_NAME);

boolean status = db.open();
// Map<String, Object> objs = db.getAllDocs(null);

String dDocName = "ddoc";
String viewName = "allgames";

TDView allView = db.getViewNamed(String.format("%s/%s", dDocName,
viewName));

allView.setMapReduceBlocks(new TDViewMapBlock()
{
public void map(Map<String, Object> document, TDViewMapEmitBlock emitter)
{
String type = (String) document.get("type");

if (type.equals("game") == true)
{
emitter.emit(null, document.get("_id"));

}
}
}, new TDViewReduceBlock()

{
public Object reduce(List<Object> keys, List<Object> values, boolean
rereduce)
{
return null;
}
}, "1.0");

ViewQuery viewQuery = new ViewQuery().designDocId("_design/" +
dDocName).viewName(viewName);

CouchDbInstance dbInstance = Global.getLocalCouchInstance(MainMenu.this);
CouchDbConnector connect = dbInstance.createConnector("yourteam", false);
List<String> ids = connect.getAllDocIds();
ViewResult viewResult = connect.queryView(viewQuery);

07-25 21:41:41.876: E/TDDatabase(8841): Exception in TDRouter
07-25 21:41:41.876: E/TDDatabase(8841):
java.lang.reflect.InvocationTargetException
07-25 21:41:41.876: E/TDDatabase(8841): at
java.lang.reflect.Method.invokeNative(Native Method)
07-25 21:41:41.876: E/TDDatabase(8841): at
java.lang.reflect.Method.invoke(Method.java:507)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.router.TDRouter.start(TDRouter.java:367)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.ektorp.TouchDBHttpClient.executeRequest(TouchDBHttpCl ient.java:207)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.ektorp.TouchDBHttpClient.get(TouchDBHttpClient.java:7 0)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.ektorp.TouchDBHttpClient.getUncached(TouchDBHttpClien t.java:78)
07-25 21:41:41.876: E/TDDatabase(8841): at
org.ektorp.http.RestTemplate.getUncached(RestTemplate.java:26)
07-25 21:41:41.876: E/TDDatabase(8841): at
org.ektorp.impl.StdCouchDbConnector.executeQuery(StdCouchDbConnector.java:4 10)
07-25 21:41:41.876: E/TDDatabase(8841): at
org.ektorp.impl.StdCouchDbConnector.queryView(StdCouchDbConnector.java:449)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.yourteam.MainMenu$1.handleMessage(MainMenu.java:136)
07-25 21:41:41.876: E/TDDatabase(8841): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-25 21:41:41.876: E/TDDatabase(8841): at
android.os.Looper.loop(Looper.java:150)
07-25 21:41:41.876: E/TDDatabase(8841): at
android.app.ActivityThread.main(ActivityThread.java:4333)
07-25 21:41:41.876: E/TDDatabase(8841): at
java.lang.reflect.Method.invokeNative(Native Method)
07-25 21:41:41.876: E/TDDatabase(8841): at
java.lang.reflect.Method.invoke(Method.java:507)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 839)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-25 21:41:41.876: E/TDDatabase(8841): at
dalvik.system.NativeStart.main(Native Method)
07-25 21:41:41.876: E/TDDatabase(8841): Caused by:
java.lang.NullPointerException
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.router.TDRouter.compileView(TDRouter.java:1267)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.router.TDRouter.queryDesignDoc(TDRouter.java:1307)
07-25 21:41:41.876: E/TDDatabase(8841): at
com.couchbase.touchdb.router.TDRouter.do_GET_DesignDocument(TDRouter.java:1 359)
07-25 21:41:41.876: E/TDDatabase(8841): ... 18 more
07-25 21:41:42.256: D/dalvikvm(8841): GC_CONCURRENT freed 346K, 40% free
4381K/7239K, external 0K/0K, paused 3ms+3ms
07-25 21:41:57.001: I/dalvikvm(8841): threadid=4: reacting to signal 3
07-25 21:41:57.011: D/dalvikvm(8841): threadid=1: still suspended after
undo (sc=1 dc=1)
07-25 21:41:57.011: I/dalvikvm(8841): Wrote stack traces to
'/data/anr/traces.txt'
07-25 21:41:59.543: D/AndroidRuntime(8841): Shutting down VM

07-25 21:41:59.543: W/dalvikvm(8841): threadid=1: thread exiting with
uncaught exception (group=0x4001d5a0)
07-25 21:41:59.603: E/AndroidRuntime(8841): FATAL EXCEPTION: main
07-25 21:41:59.603: E/AndroidRuntime(8841): org.ektorp.DbAccessException:
com.couchbase.touchdb.ektorp.TouchDBHttpResponse@405e3988
07-25 21:41:59.603: E/AndroidRuntime(8841): URI:
touchdb:/yourteam/_design/ddoc/_view/allgames
07-25 21:41:59.603: E/AndroidRuntime(8841): Response Body:
07-25 21:41:59.603: E/AndroidRuntime(8841): null
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandl er.java:44)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:107)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.http.RestTemplate.getUncached(RestTemplate.java:27)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.impl.StdCouchDbConnector.executeQuery(StdCouchDbConnector.java:4 10)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
org.ektorp.impl.StdCouchDbConnector.queryView(StdCouchDbConnector.java:449)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
com.yourteam.MainMenu$1.handleMessage(MainMenu.java:136)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
android.os.Looper.loop(Looper.java:150)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
android.app.ActivityThread.main(ActivityThread.java:4333)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
java.lang.reflect.Method.invokeNative(Native Method)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
java.lang.reflect.Method.invoke(Method.java:507)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 839)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-25 21:41:59.603: E/AndroidRuntime(8841): at
dalvik.system.NativeStart.main(Native Method)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 26 2012, 9:36 am
From: Marty Schoch <marty.sch...@gmail.com>
Date: Thu, 26 Jul 2012 09:36:22 -0400
Local: Thurs, Jul 26 2012 9:36 am
Subject: Re: DBAccessException on .queryView()
After looking at the stack trace I see that it did not find the map
reduce block you registered, instead it found a design document
(actual JSON document) and was trying to compile the javascript.  This
ultimately led to an NPE (though my line numbers don't match up, so I
can't tell exactly why).

Obviously you intended to use the Java map/reduce block anyway.  So
the real question is why didn't it find it.

You install the view in the database Global.YOURTEAM_DB_NAME, then you
try to access it in "yourteam".  Can you double check that the
constant matches this literal value?

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 26 2012, 9:19 pm
From: matt martin <matt.m.u...@gmail.com>
Date: Thu, 26 Jul 2012 18:19:27 -0700 (PDT)
Local: Thurs, Jul 26 2012 9:19 pm
Subject: Re: DBAccessException on .queryView()

Marty,

Thanks for the response. I verified that the strings match and changed
"yourteam" to match that constant.  It sounds like it was finding an old
design document I had created (the one you mentioned) so I went ahead and
deleted the database so as to start out fresh. My stack trace has now
changed to:

07-26 18:16:00.002: E/AndroidRuntime(14151):
org.ektorp.DocumentNotFoundException: nothing found on db path:
touchdb:/yourteam/_design/ddoc/_view/allgames, Response body: null
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandl er.java:34)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:107)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.http.RestTemplate.getUncached(RestTemplate.java:27)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.impl.StdCouchDbConnector.executeQuery(StdCouchDbConnector.java:4 10)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
org.ektorp.impl.StdCouchDbConnector.queryView(StdCouchDbConnector.java:449)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
com.yourteam.MainMenu$1.handleMessage(MainMenu.java:139)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
android.os.Looper.loop(Looper.java:150)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
android.app.ActivityThread.main(ActivityThread.java:4333)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
java.lang.reflect.Method.invokeNative(Native Method)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
java.lang.reflect.Method.invoke(Method.java:507)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 839)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-26 18:16:00.002: E/AndroidRuntime(14151): at
dalvik.system.NativeStart.main(Native Method)

It looks like the design document just isn't saving to the database.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 27 2012, 9:13 am
From: Marty Schoch <marty.sch...@gmail.com>
Date: Fri, 27 Jul 2012 09:13:33 -0400
Local: Fri, Jul 27 2012 9:13 am
Subject: Re: DBAccessException on .queryView()

We don't ever actually create a design document with that view,
instead we match requests for views against the list of registered
views.  But, the effect is the same here, its just not finding the
view you registered.  It still seems like its looking in the wrong
database.

I took your code, and just replaced references to the Global object
with these hard-coded values and it works fine.  Can you try this and
see if it works for you:

        TDDatabase db = server.getDatabaseNamed("yourteam");

        boolean status = db.open();

        String dDocName = "ddoc";
        String viewName = "allgames";

        TDView allView = db.getViewNamed(String.format("%s/%s",
dDocName, viewName));

        allView.setMapReduceBlocks(new TDViewMapBlock()
        {
            public void map(Map<String, Object> document,
TDViewMapEmitBlock emitter)
            {
                String type = (String) document.get("type");

                if (type.equals("game") == true)
                {
                    emitter.emit(null, document.get("_id"));
                }
            }
        }, new TDViewReduceBlock()
        {
            public Object reduce(List<Object> keys, List<Object>
values, boolean rereduce)
            {
                return null;
            }
        }, "1.0");

        ViewQuery viewQuery = new ViewQuery().designDocId("_design/" +
dDocName).viewName(viewName);

        HttpClient httpClient = new TouchDBHttpClient(server);
        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
        CouchDbConnector connect =
dbInstance.createConnector("yourteam", false);
        List<String> ids = connect.getAllDocIds();
        ViewResult viewResult = connect.queryView(viewQuery);

        server.close();


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 28 2012, 3:09 am
From: matt martin <matt.m.u...@gmail.com>
Date: Sat, 28 Jul 2012 00:09:31 -0700 (PDT)
Local: Sat, Jul 28 2012 3:09 am
Subject: Re: DBAccessException on .queryView()

The error was in my getLocalCouchInstance function. It fails when I get the
db instance from that function but works when I hard code like in your
above code.

Here is the function. Maybe you can shed some light on what I'm doing wrong
here. I appreciate the help. You are great.

CouchDbInstance dbInstance = null;

{
TDURLStreamHandlerFactory.registerSelfIgnoreError();

}

TDServer server = null;
String filesDir = mContext.getFilesDir().getAbsolutePath();

try
{
server = new TDServer(filesDir);
org.ektorp.http.HttpClient httpClient = new TouchDBHttpClient(server);
dbInstance = new StdCouchDbInstance(httpClient);

// Try and create a database. Throws exception if db exists.
try
{
dbInstance.createDatabase(Global.YOURTEAM_DB_NAME);

}

catch (DbAccessException e)
{
e.printStackTrace();
}
}

catch (IOException e)
{
e.printStackTrace();
Log.e("touchdb", "Error starting TDServer", e);

}

return dbInstance;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 28 2012, 10:39 am
From: Marty Schoch <marty.sch...@gmail.com>
Date: Sat, 28 Jul 2012 10:39:19 -0400
Local: Sat, Jul 28 2012 10:39 am
Subject: Re: DBAccessException on .queryView()

On Sat, Jul 28, 2012 at 3:09 AM, matt martin <matt.m.u...@gmail.com> wrote:
> The error was in my getLocalCouchInstance function. It fails when I get the
> db instance from that function but works when I hard code like in your above
> code.

> Here is the function. Maybe you can shed some light on what I'm doing wrong
> here. I appreciate the help. You are great.

I think the problem is that you are creating new TDServer instances
each time.  Behind the scenes they are creating different TDDatabase
objects in memory, that work with the same database on disk.  There
are some use cases where that is desirable, but this isn't one of
them.  Can you change the code to keep a reference to the TDServer and
reuse it on subsequent calls?

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 29 2012, 6:18 pm
From: matt martin <matt.m.u...@gmail.com>
Date: Sun, 29 Jul 2012 15:18:01 -0700 (PDT)
Local: Sun, Jul 29 2012 6:18 pm
Subject: Re: DBAccessException on .queryView()

I did just that and it cleaned up my code nicely, thanks.

As an aside, does TouchDB support back references when fetching documents
yet? My game object has a backreference like so:

@DocumentReferences(backReference = "game", fetch = FetchType.LAZY,
descendingSortOrder = true, orderBy = "dateCreated")
private Set<MyObject> objects;

Getting the following exception:

07-29 13:17:11.015: E/AndroidRuntime(1517): Caused by:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized
field "team" (Class com.yourteam.Game), not marked as ignorable
07-29 13:17:11.015: E/AndroidRuntime(1517):  at [Source:
java.io.ByteArrayInputStream@40763688; line: 1, column: 10] (through
reference chain: com.yourteam.Game["team"])
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldExcept ion(StdDeserializationContext.java:267)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(St dDeserializer.java:649)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(St dDeserializer.java:635)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanD eserializer.java:1355)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanD eserializer.java:717)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserialize r.java:580)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.ektorp.impl.docref.BackReferencedBeanDeserializer.deserialize(BackRefer encedBeanDeserializer.java:43)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:27 23)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1900)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.ektorp.impl.StdCouchDbConnector$3.success(StdCouchDbConnector.java:241)
07-29 13:17:11.015: E/AndroidRuntime(1517): at
org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:107)
07-29 13:17:11.015: E/AndroidRuntime(1517): ... 15 more


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 29 2012, 8:12 pm
From: matt martin <matt.m.u...@gmail.com>
Date: Sun, 29 Jul 2012 17:12:22 -0700 (PDT)
Local: Sun, Jul 29 2012 8:12 pm
Subject: Re: DBAccessException on .queryView()

Looks like this is related to it still not finding / using the correct
view. I am doing a replication pull before the query. Could this be causing
issues?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 29 2012, 9:55 pm
From: Marty Schoch <marty.sch...@gmail.com>
Date: Sun, 29 Jul 2012 21:55:26 -0400
Local: Sun, Jul 29 2012 9:55 pm
Subject: Re: DBAccessException on .queryView()

On Sun, Jul 29, 2012 at 6:18 PM, matt martin <matt.m.u...@gmail.com> wrote:
> I did just that and it cleaned up my code nicely, thanks.

> As an aside, does TouchDB support back references when fetching documents
> yet?

They are not supported because Ektorp transparently generates views in
the background to support them.  We have to teach Ektorp how to build
Java views instead of Javascript views.

> My game object has a backreference like so:

> @DocumentReferences(backReference = "game", fetch = FetchType.LAZY,
> descendingSortOrder = true, orderBy = "dateCreated")
> private Set<MyObject> objects;

> Getting the following exception:

> 07-29 13:17:11.015: E/AndroidRuntime(1517): Caused by:
> org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized
> field "team" (Class com.yourteam.Game), not marked as ignorable

This particular exception has to do with a field in the JSON "team"
not being mapped in the Java class.

See http://stackoverflow.com/questions/4486787/jackson-json-unrecognized-...

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 29 2012, 9:57 pm
From: Marty Schoch <marty.sch...@gmail.com>
Date: Sun, 29 Jul 2012 21:57:17 -0400
Local: Sun, Jul 29 2012 9:57 pm
Subject: Re: DBAccessException on .queryView()

On Sun, Jul 29, 2012 at 8:12 PM, matt martin <matt.m.u...@gmail.com> wrote:
> Looks like this is related to it still not finding / using the correct view.
> I am doing a replication pull before the query. Could this be causing
> issues?

I'm not sure how you came to this conclusion.  Can you provide more
information about what the view returned and what you expected it to
return?

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 30 2012, 1:36 pm
From: matt martin <matt.m.u...@gmail.com>
Date: Mon, 30 Jul 2012 10:36:13 -0700 (PDT)
Local: Mon, Jul 30 2012 1:36 pm
Subject: Re: DBAccessException on .queryView()

'team' is an attribute in another document type that is not present in
Game. My map function should be filtering out all documents that aren't
Game type.

  String type = (String) document.get("type");

Log.i("mapreduce", document.get("_id").toString());
 if (type.equals("game"))
{
emitter.emit(null, document.get("_id"));

}

Additionally, I have a breakpoint set in my map function and it's never
hit. This leads me to believe that a different map function is being used.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matt martin  
View profile  
 More options Jul 31 2012, 2:27 am
From: matt martin <matt.m.u...@gmail.com>
Date: Mon, 30 Jul 2012 23:27:13 -0700 (PDT)
Local: Tues, Jul 31 2012 2:27 am
Subject: Re: DBAccessException on .queryView()

In the wiki example, the ObjectRepository looks like so:

public class EmailAccountRepository extends CouchDbRepositorySupport<EmailAccount> {
        public EmailAccountRepository(CouchDbConnector couchDBConnector) {
                super(EmailAccount.class, couchDBConnector);
        }*}*

When I use this model the UnrecognizedPropertyException is thrown and my
map breakpoint is never hit (even in an unindexed view).

If I add an overridden getAll() method to my RepositorySupport class, my
map block executes as expected and no exceptions are thrown.

*public class GameRepository extends CouchDbRepositorySupport<Game>
{
        public GameRepository(CouchDbConnector db)
        {
                super(Game.class, db);
        }

        @Override @GenerateView
        public List<Game> getAll()
        {
                ViewQuery q = createQuery("all").descending(true);
        return db.queryView(q, Game.class);
        }

}*

Is the code on the wiki outdated?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Jul 31 2012, 9:11 am
From: Marty Schoch <marty.sch...@gmail.com>
Date: Tue, 31 Jul 2012 09:11:56 -0400
Local: Tues, Jul 31 2012 9:11 am
Subject: Re: DBAccessException on .queryView()

I think it just has to do with the behavior of
CouchDbRepositorySupport.getAll().  It first checks to see if a design
document with a particular name exists (the name uses Ektorp's
conventions which I think would be something like _design/Game in this
case).  In your case I'm presuming that will not find a document with
this name.  It then proceeds to use _all_docs.

This would seem to explain the behavior you're seeing, your breakpoint
in the view isn't hit, and since _all_docs will return documents not
of type "game" it could then cause the mapping exception as well.

When you override the getAll() method you're skipping the check for
the design doc, and directly pointing it at your view.

I can see how the wiki is confusing here, it may work for the wrong
reasons depending on what your data looks like.  It would be great if
you could suggest a better way once you have it working for yourself.
We definitely need more people contributing to the wiki.

There is a larger issue that is starting to surface here.  Ideally
CouchDbRepositorySupport would behave a little differently for
TouchDB.  For example, instead of looking up a design doc in the
database, it could check the list of views registered in memory.  In
my mind the right way for us to tackle this is to have a separate
implementation of the CouchDbInstance and CouchDbConnector classes
that are specific to TouchDB.  If we do this right, we could start to
remove some of the TDRouter layer as well (I see this as analogous to
what Jens wants to do with TouchDB-iOS and CouchCocoa in the future).
I'd love to dive into this now because it offers potential performance
improvements too (there are places where TouchDB and Ektorp serialize
and deserialize the same data which could have been returned straight
through with TouchDB), but I really see this as an improvement for
TouchDB-Ektorp 1.1.

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Martin  
View profile  
 More options Aug 1 2012, 1:56 am
From: Matt Martin <matt.m.u...@gmail.com>
Date: Tue, 31 Jul 2012 22:56:45 -0700 (PDT)
Local: Wed, Aug 1 2012 1:56 am
Subject: Re: DBAccessException on .queryView()

>I can see how the wiki is confusing here, it may work for the wrong
>reasons depending on what your data looks like.  It would be great if
>you could suggest a better way once you have it working for yourself.
>We definitely need more people contributing to the wiki.  

I'm not sure I will find a way to get it working. I believe it will
require, as you say, some modification to the RepositorySupportClass for
TouchDB. I'm currently stepping through some of the MapReduce related
methods in TDView but the code is all very new to me. I'll see what I can
find out in the coming days and let you know if I find a solution.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Martin  
View profile  
 More options Aug 1 2012, 11:31 pm
From: Matt Martin <matt.m.u...@gmail.com>
Date: Wed, 1 Aug 2012 20:31:19 -0700 (PDT)
Local: Wed, Aug 1 2012 11:31 pm
Subject: Re: DBAccessException on .queryView()

Can you verify that mapreduce is functioning in TouchDB at all? I have
defaulted back to a standard view query.

*ViewQuery viewQuery = new ViewQuery().designDocId("_design/" + "ddoc").viewName("games");
  //viewQuery.descending(true); //use this to reverse the sorting order of the view
ViewResult viewResult = connect.queryView(viewQuery);

for (ViewResult.Row row : viewResult)
{
        String id = row.getValue();
        id = row.getValue();

}*

I am not able to do much of anything with row. getDoc(), getKey(), and
getValue() all return null. This was the same behavior (empty set returned)
I saw when performing a MapReduce through the RepositorySupportClass.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marty Schoch  
View profile  
 More options Aug 2 2012, 4:39 pm
From: Marty Schoch <marty.sch...@gmail.com>
Date: Thu, 2 Aug 2012 16:39:29 -0400
Local: Thurs, Aug 2 2012 4:39 pm
Subject: Re: DBAccessException on .queryView()

I think its working.  I've tried your code, with the view definitions
I think you're using.

NOTE: I'm assuming you changed the view name to "games" from
"allgames".  The code did not work until I made that change.

The code I'm running is here:

http://pastebin.com/cq8egGWr

The output it generates is here:

http://pastebin.com/q62dJuGQ

The reason the value is null is because you have a reduce function
defined.  And if you have one defined, querying the view will reduce
by default.  You can disable reduce if you want by adding
.reduce(false) to the ViewQuery.

If I add the to the ViewQuery, the results change to:

08-02 16:37:56.132: D/TestAppActivity(668): row value is
825d331c-eea7-4aec-91dc-df8ce9583b9e

marty


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Martin  
View profile  
 More options Aug 4 2012, 1:12 pm
From: Matt Martin <matt.m.u...@gmail.com>
Date: Sat, 4 Aug 2012 10:12:16 -0700 (PDT)
Local: Sat, Aug 4 2012 1:12 pm
Subject: Re: DBAccessException on .queryView()

Setting reduce to false did it, thanks. I would be happy to contribute to
the wiki once I get some more experience with the API. The wiki definitely
needs more attention and I can appreciate that you're busy as it is.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »