Question

I have relationship many to many with one entity on the middle.

This is my model declaration:

//### Family

    Entity family = schema.addEntity("Family");
    Property familyId = family.addIdProperty().getProperty();
    family.addStringProperty("zid_family").notNull();
    family.addStringProperty("zglosa");
    family.addStringProperty("zidioma");
    family.addIntProperty("zposicion");
    family.addIntProperty("zestado");


    //### Tax Family

    Entity taxFamily = schema.addEntity("TaxFamily");
    Property taxFamilyId = taxFamily.addIdProperty().getProperty();
    taxFamily.addStringProperty("zid_family").notNull();
    taxFamily.addStringProperty("zid_tax").notNull();


    //### Tax

    Entity tax = schema.addEntity("Tax");
    Property taxId = tax.addIdProperty().getProperty();
    tax.addStringProperty("zid_tax").notNull();
    tax.addStringProperty("zglosa");
    tax.addStringProperty("zpais");
    tax.addIntProperty("ztype");
    tax.addFloatProperty("zvalor");


    //@@@ Relatinships

    //family
    ToMany familyToTaxFamily = family.addToMany(taxFamily, taxFamilyId);
    familyToTaxFamily.setName("taxs_family");
    familyToTaxFamily.orderAsc(taxFamilyId);

    //tax
    ToMany taxToTaxFamily = tax.addToMany(taxFamily, taxFamilyId);
    taxToTaxFamily.setName("familys_tax");
    taxToTaxFamily.orderAsc(taxFamilyId);

    taxFamily.addToOne(family, familyId);
    taxFamily.addToOne(tax, taxId);

The problem is i not find the way and any documentation for implement something like this:

List<Tax> result = taxDao.queryBuilder().where(taxDao.Properties.Ztype.eq(TAX_DETAIL_TYPE)).and(ImpuestoDao.ToMany("familys_tax").Zid_family.eq(ID_FAMILY)).list();

UPDATED:

If it is not clear: I need something like this predicate

type == <TYPE_TAX> AND ANY familys_tax.id_family == <ID_FAMILY>

Any familys_tax objects of Tax have id_family equal to ID_FAMILY

Many thanks!

Was it helpful?

Solution

greenDao not support joins with queryBuilder

Joins only with queryRaw.

My case:

String stringRawquery = ", TaxFamily TFAM WHERE T.ZTyPe=" + TAX_TYPE + " AND IFAM.ZID_FAMILY='"+idFamily+"' AND IFAM.ZID_TAX = T.ZID_TAX";
List<Tax> result = taxDao.queryRawCreate(stringRawquery).list();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top