具有关系对象条件的greenDao queryBuilder

时间:2014-03-04 04:11:40

标签: android orm greendao

我与中间的一个实体有许多关系。

这是我的模范声明:

//### 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);

问题是我没有找到方法和任何文档来实现这样的东西:

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

更新:

如果不清楚: 我需要像这个谓词

这样的东西
type == <TYPE_TAX> AND ANY familys_tax.id_family == <ID_FAMILY>

Tax的任何familys_tax对象的id_family等于ID_FAMILY

非常感谢!

1 个答案:

答案 0 :(得分:0)

greenDao不支持与queryBuilder的连接

仅与queryRaw合作。

我的情况:

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();