2014-03-04 63 views
0

我與中間的一個實體有多對多的關係。帶關係對象條件的greenDao queryBuilder

這是我的模型聲明:

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

任何稅款familys_tax對象有id_family等於ID_FAMILY

非常感謝!

回答

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