OFBiz Study notes 01--multi-Table Association query

Source: Internet
Author: User

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

    1. Realization One: Screem.xml in the section , add <action>, plus get-related
    2. Implement two: Use dynamicviewentity object in code, add Addmemberentity,addalias,addviewlink, then use find query
    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.