how to query for sub object in one of the table in db4o?

35 Views Asked by At

I am implementing app on android and for the same using DB4o.v In one table/object I am storing like List category. In class1 I have 2 members like name and ID....

I have to fetch all the records by comparing class1.name..How could I do this?

I tried using query.descend("name").constrain(value) and query.descend("class1.name").constrain(value), but it did not fetch the records...

Can any one help me please?

1

There are 1 best solutions below

0
user3863488 On

I found answer for this...

Made one common id for both objects I tried to first get all sub class records then from sub class and then using the id of sub class got results for the required class.

Read category object which matches for the required name...using this object id read class1 object..Like,

List<Category> categories =  dbService.getResultsById(Category.class, "name", category);
if (categories != null && categories.size() > 0) {

    for (Category testCategory : categories) {
        return dbService.getResultsById(class1.class, "id", testCategory.id);
    }
}

This is working.