No matter what the project, will certainly use the Multi-table association query data, from the network query learned that OFBiz has three kinds of multi-table association Query method
- Realization One: Screem.xml in the section , add <action>, plus get-related
- Implement two: Use dynamicviewentity object in code, add Addmemberentity,addalias,addviewlink, then use find query
- Implementation three: define the view-entity entity object in Entity.xml, check the object of this view when querying
1, the method is not written out, later to add
2, use Finddlistiteratatorbycondtion to find him.
Dynamicviewentity DVE =Newdynamicviewentity (); Dve.addmemberentity ("TT", "AA"); Dve.addalias ("TT", "UserName"); Dve.addalias ("tt", "Sex"); Dve.addrelation ("One", "", "BB", Utilmisc.tolist (NewModelkeymap ("UserName", "UserName"))); Dve.addmemberentity ("TE", "BB"); Dve.addalias ("TE", "UserName"); Dve.addalias ("TE", "Name"); Dve.addrelation ("One", "" "," AA ", Utilmisc.tolist (NewModelkeymap ("UserName", "UserName"))); Dve.addviewlink ("TE", "tt",false, Utilmisc.tolist (NewModelkeymap ("UserName", "UserName"))); Entitylistiterator Salesusageit= Delegator.findlistiteratorbycondition (DVE,NULL,NULL,NULL,NULL,NULL ); List= Salesusageit.getcompletelist ();
3, the method according to my understanding is equivalent to the usual according to a few tables to build a view view, and then query the view
Configure view-entity, then check this view.
<view-entity entity-name= "Vview" package-name= "Org.ofbiz.test" > < Member-entity entity-alias= "TY" entity-name= "AA" ></member-entity> <member-entity entity-alias= "TT" Enti Ty-name= "BB" ></member-entity> <alias-all entity-alias= "TY"/> <alias name= "UserName" entity -alias= "Ty" group-by= "true"/> <alias name= "userName" entity-alias= "ty"/><alias name= "Sex" entity-alias= "TY"/> <alias name= "name" entity-alias= "tt"/> <alias name= "Address" entity-alias= "TT"/> <alias name= "UserName" entity-alias= "TY" field= "UserName" col-alias= "UserName"/> <view-link entity-alia s= "TY" rel-entity-alias= "TT" > <key-map field-name= "userName" rel-field-name= "UserName"/> </v iew-link> <alias name= "UserName" entity-alias= "TT" field= "UserName" col-alias= "UserName"/> </view-en Tity>
OFBiz Study notes 01--multi-Table Association query