Any of the query methods in the ektorp class : http://ektorp.org/javadoc/ektorp/1.2.2/org/ektorp/support/CouchDbRepositorySupport.html
i.e. protected List<http://download.oracle.com/javase/6/docs/api/java/util/List.html?is-external=true> <T<http://ektorp.org/javadoc/ektorp/1.2.2/org/ektorp/support/CouchDbRepositorySupport.html> >*queryView <http://ektorp.org/javadoc/ektorp/1.2.2/org/ektorp/support/CouchDbRepositorySupport.html#queryView(java.lang.String, int)>*(String<http://download.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true> viewName, int key) Allows subclasses to query views with simple String value keys and load the result as the repository's handled type. Assuming we have all the correct views. We instance this class below with db connector and execute the method : import org.ektorp.support.CouchDbRepositorySupport; public class EmployeeDaoImpl extends CouchDbRepositorySupport<Employee> implements Employee { public EmployeeDaoImpl (final CouchDbConnector db) { super(Employee.class, db); } @Override public Table findByCompanyAndName(final String company, final String name) { * final List<Employee> result = db.queryView(createQuery("by_company_and_name").key(ComplexKey.of(company,* * name)), Employee.class);* if (result.size() == 0) { return null; } return result.get(0); } } *result *is an empty collection when querying like that even when data exists. When querying like you did, NOT using CouchDbRepositorySupport like in your tests it works with no problem. Hope is clearer now. On Mon, Feb 17, 2014 at 6:37 PM, Traun Leyden <[email protected]>wrote: > I'm a little confused, can you give a concrete example of a query that > doesn't work? > > > > > On Sun, Feb 16, 2014 at 11:28 PM, bpolan <[email protected]> wrote: > >> Hi Traun , >> >> I tried the test cases and this works with no problem. This in the tests >> is the second way I tried where you don't use >> the CouchDbRepositorySupport<?> which gives ability to implement CRUD "out >> of box" >> http://ektorp.org/javadoc/ektorp/1.2.2/org/ektorp/support/CouchDbRepositorySupport.html. >> >> If you try to query views via mentioned class it does not work ok, while >> create, update, delete work ok. >> I am using now approach like in the tests for querying and for create, >> read, update, the mentioned class support. >> >> Thanks for help! >> >> On Saturday, February 15, 2014 1:54:16 AM UTC+1, Traun Leyden wrote: >> >>> >>> I just updated the couchbase-lite-android-ektorp project so that the >>> tests are passing (was just some API renames that broke tests compilation) >>> >>> Can you check out the tests here: >>> >>> https://github.com/couchbaselabs/couchbase-lite- >>> android-ektorp/blob/master/src/instrumentTest/java/com/ >>> couchbase/lite/testapp/ektorp/tests/Views.java#L86-L157 >>> >>> and try to see what you are doing differently than the tests? >>> >>> On Thursday, February 13, 2014, bpolan <[email protected]> wrote: >>> >>>> * db*.queryView(createQuery(ViewsEmployee.BY_TAG_ID).key(tag), >>>> *CouchDbTable.class)*; is Employee.class typo in last post >>>> >>>> On Thursday, February 13, 2014 11:00:28 PM UTC+1, bpolan wrote: >>>>> >>>>> Thanks, >>>>> >>>>> then the problem I have is not there. >>>>> >>>>> public class EmployeeDaoImpl extends CouchDbRepositorySupport<Employee> >>>>> implements EmployeeDao { >>>>> >>>>> private CouchDbConnector *dba*; >>>>> >>>>> public EmployeeDaoImpl(CouchDbConnector db) { >>>>> super(Employee.class, *db*); >>>>> this.dba = db; >>>>> } >>>>> >>>>> *When I use Ektorps CouchDbRepositorySupport class queries return >>>>> nothing:* >>>>> >>>>> * db*.queryView(createQuery(ViewsEmployee.BY_TAG_ID).key(tag), >>>>> CouchDbTable.class); >>>>> >>>>> *When I bypass CouchDbRepositorySupport i get results : * >>>>> >>>>> ViewQuery viewQuery = new ViewQuery().designDocId("_design/" >>>>> + ViewsEmployee.DESIGN_DOC).viewName(ViewsEmployee.BY_TAG_ID).key(tag); >>>>> >>>>> ViewResult result = *dba*.queryView(viewQuery); >>>>> >>>>> When there is no results no error appears just result is null. So the >>>>> view is found. >>>>> Don't know what would be the problem ? >>>>> >>>>> On Thursday, February 13, 2014 10:49:09 PM UTC+1, Traun Leyden wrote: >>>>>> >>>>>> >>>>>> I just checked the commit logs and it looks like that change didn't >>>>>> make it into beta2. >>>>>> >>>>>> >>>>>> On Thu, Feb 13, 2014 at 11:30 AM, Matt Quinn <[email protected]>wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> bpolan <[email protected]> wrote: >>>>>>> >02-13 19:09:08.666: D/Database(2792): lastSequence (2061) == >>>>>>> >dbMaxSequence >>>>>>> >(2061), nothing to do >>>>>>> >*02-13 19:09:08.666: W/Database(2792): Failed to rebuild view >>>>>>> >CouchDbTable/by_company_and_name: 500* >>>>>>> > >>>>>>> >What is 500 error and why view fails to rebuild? >>>>>>> >>>>>>> This is a misleading error message. Nothing's wrong -- the view >>>>>>> isn't rebuilding because it doesn't have to (see log message one line >>>>>>> earlier). >>>>>>> >>>>>>> This has already been fixed, but I guess it didn't make it into beta >>>>>>> 2. >>>>>>> https://github.com/couchbase/couchbase-lite-java-core/pull/28 >>>>>>> >>>>>>> -- >>>>>>> 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/2ac34115- >>>>>>> b102-4243-a063-be8b37db5987%40email.android.com. >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>> >>>>>> -- >>>> 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/2201812a-f833-4e20-9168- >>>> ab961c7baeb1%40googlegroups.com. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> -- >> 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/f3bb9b18-ea56-4ed3-bbe2-975454d1245e%40googlegroups.com >> . >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Couchbase Mobile" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/mobile-couchbase/GbFXIY_XMVo/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mobile-couchbase/CACSSHCGvD-Bde%3DSmY5UBNpKM2vUw%2B7k-mt9rQXBx78vHXZjU3A%40mail.gmail.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CAMYermRRsBXaupbT0DA-3jBoyNL9RD_oZv-UxzZ8y53JAUzb2w%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
