1、 summary
    entity engine And common ORM There's a big difference , His mapping object only one GenericEntity, What do you call it entity engine by adaptive object model More appropriate , It's more flexible , A unique persistence scheme with very little code . Use entity engine Projects and other things ORM There is a very obvious feature in comparison : Very few objects
 
    be based on Entity Engine Modeling the database completely shields the differences between various databases , Can support from MySql To Oracle Almost all relational databases
 
    Entity Engine Provides a simple and effective way of data modeling , Through simple XML Files to describe entities , You don't need to write any code to create entities , Storage , Delete , lookup , Sort , You no longer need to write any code to create entities , Storage , Delete , lookup , Sort , No longer need to write and maintain data persistence code , adopt JDBC Support any kind of database
 
 
1.1 The concept of entity engine
 
    DataSource: data source , There can be multiple databases in one database entity schema, Different schema Covering the respective entities . Data sources are defined and configured in entityengine.xml in
 
    Entity Delegators: Physical agent , Use an entity agent to access the database
example :framework/entity/config/entityengine.xml

 <delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
<group-map group-name="org.ofbiz" datasource-name="localderby"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/>
</delegator>
    Entity Group: It's a group of entities under the group name , The group name is used to instruct the entity proxy class to determine which data source these entities use
 
Entity definition
example :applications/product/entitydef/entitymodel.xml
 <entity entity-name="ProdCatalog"
package-name="org.ofbiz.product.catalog"
title="Catalog Entity" default-resource-name="ProductEntityLabels">
<field name="prodCatalogId" type="id-ne"></field>
<field name="catalogName" type="name"></field>
<field name="useQuickAdd" type="indicator"></field>
<field name="styleSheet" type="url"></field>
<field name="headerLogo" type="url"></field>
<field name="contentPathPrefix" type="long-varchar"></field>
<field name="templatePathPrefix" type="long-varchar"></field>
<field name="viewAllowPermReqd" type="indicator"></field>
<field name="purchaseAllowPermReqd" type="indicator"></field>
<prim-key field="prodCatalogId"/>
</entity>
 
1.2 Entity type
 
    entity: Standard entities , yes MVC Models in Architecture (MODEL) The basic unit of ; To put it simply , It's just a database table .
 
    view-entity: View , Usually a collection of member entities connected by a series of relationships
 
    extend-view: Extended entities , Entities can pass through <extend-entity> Elements to extend
 
2.1 Standard entities (entity)
    attribute :

entity-name: The entity name

    table-name: Table name
    package-name: Package name
    default-resource-name: Default resource file name
    dependent-on: Specify the parent entity and the dependent entity , Only used to specify hierarchical entity structure
    sequence-bank-size: Serial number step size
    enable-lock: Whether to use optimized lock on this entity
    Subelement :

description: explain

    field: Field
    prim-key: Primary key
    relation: Relationship
    copyright: Copyright
    index: Indexes

example :framework/security/entitydef/entitymodel.xml

<entity entity-name="UserLogin"
package-name="org.ofbiz.security.login"
title="User Login Entity">
<field name="userLoginId" type="id-vlong-ne"></field>
<field name="currentPassword" type="short-varchar"></field>
<field name="passwordHint" type="description"></field>
<field name="isSystem" type="indicator"></field>
<field name="enabled" type="indicator"></field>
<field name="hasLoggedOut" type="indicator"></field>
<field name="requirePasswordChange" type="indicator"></field>
<field name="lastCurrencyUom" type="id"></field>
<field name="lastLocale" type="very-short"></field>
<field name="lastTimeZone" type="id-long"></field>
<field name="disabledDateTime" type="date-time"></field>
<field name="successiveFailedLogins" type="numeric"></field>
<field name="externalAuthId" type="id-vlong-ne">
<description>For use with external authentication; the userLdapDn should be replaced with this</description>
</field>
<field name="userLdapDn" type="id-vlong-ne">
<description>The user's LDAP Distinguished Name - used for LDAP authentication</description>
</field>
<prim-key field="userLoginId"/> </entity>
2.2 View (view-entity)
    attribute :
    entity-name: The entity name
    package-name: Package name
    dependent-on: Dependency relationship
    default-resource-name: Default resource name
    never-cache: Never cache
    auto-clear-cache: Automatically clear cache
    title: title
    copyright: Copyright
    author: author
    version: edition
    Subelement :
    description: explain
    member-entity: Member entities
    alias-all: All aliases
    alias: Alias
    view-link: Trying to connect
    relation: Relationship
example :applications/party/entitydef/entitymodel.xml
 <view-entity entity-name="PartyAndUserLogin"
package-name="org.ofbiz.party.party"
title="Party and Contact Mech View Entity">
<member-entity entity-alias="PTY" entity-name="Party"/>
<member-entity entity-alias="ULN" entity-name="UserLogin"/>
<alias entity-alias="PTY" name="partyId"/>
<alias entity-alias="PTY" name="partyTypeId"/>
<alias entity-alias="ULN" name="userLoginId"/>
<alias entity-alias="ULN" name="currentPassword"/>
<alias entity-alias="ULN" name="passwordHint"/>
<alias entity-alias="ULN" name="enabled"/>
<alias entity-alias="ULN" name="disabledDateTime"/>
<alias entity-alias="ULN" name="successiveFailedLogins"/>
<view-link entity-alias="PTY" rel-entity-alias="ULN">
<key-map field-name="partyId"/>
</view-link>
<relation type="one-nofk" rel-entity-name="Party">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="UserLogin">
<key-map field-name="userLoginId"/>
</relation>
</view-entity>

2.3 Expansion tries to (extend-entity)

    attribute :
    entiy-name: The entity name
    Subelement
    field: Field
    relation: Relationship
    index: Indexes
example :applications/party/entitydef/entitymodel.xml
 <extend-entity entity-name="UserLogin">
<field name="partyId" type="id"></field>
<relation type="one" fk-name="USER_PARTY" rel-entity-name="Party">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="Person">
<key-map field-name="partyId"/>
</relation>
<relation type="one-nofk" rel-entity-name="PartyGroup">
<key-map field-name="partyId"/>
</relation>
</extend-entity>

3、GenericValue object

    One GenericValue An object is a record of a database entity
4、 establish 、 to update 、 Delete 、 Database records
4、1 Create entities
1、 obtain GenericValue Entity object
OFBiz There are many ways to get entity objects in , The following methods are recommended
GenericValue tempValue = delegator.makeValue("EntityName");
 
 
4、2 Update entity
 
4、3 Delete entities
 
 
5、 Several kinds of database records
5.1 Several common query methods
Query by primary key :public GenericValue findByPrimaryKey(String entityName,Map<String ,? extends Object> fields)
Specified field (and Combine ) Inquire about :public List<GenericValue> findByAnd(String entityName,Map<String,? extends Object> fields)
Conditions of the query :public List<GenericValue> findList(String entityName,EntityCondition entityCondition,Set<String> fieldsToSelect,List<String> orderBy,EntityFindOptions findOptions,boolean useCache)
Query list :public List<GenericValue> findList(String entityName,EntityCondition entityCondition,Set<String> fieldsToSelect,List<String> orderBy,EntityFindOptions findOptions,boolean useCache)
Parameter description :
String entityName: Entities to query and record
EntityCondition entityCondition : Restrictions on access
Set fieldsToSelect : Returns the field obtained by the record ,null For all
List orderBy : Sort field ,null Order
EntityFindOptions findOptions find option
boolean useCache Whether to use cache
 
6、 Dynamic view entities
DynamicViewEntity Dynamic view
    
EntityCondition Conditions
EntityFunction function
EntityOperator operation
EntityFindOptions Query options
EntityListIterator iterator

Apache OFBiz Learning notes And More articles on entity engine

  1. Apache OFBiz Learning notes And Service engine Two

    Load the service definition file   ofbiz-component.xml: All the service definition files are in the ofbi-component.xml In file   Load the service definition example :framework/common/ofbi ...

  2. Apache OFBiz Learning notes And Service engine One

    summary     Services are defined as a separate logical sequence , When multiple services are combined, different types of business requirements can be fulfilled     There are many types of services ,WorkFlow.Rules.Java.SOAP.BeanShell etc. .java Type of ...

  3. Apache Flink Learning notes

    Apache Flink Learning notes brief introduction The computing engine of big data is divided into 4 generation first generation :Hadoop Carrying MapReduce. It divides the calculation into two phases , Respectively Map and Reduce. For upper applications , We have to find a way to split the algorithm ...

  4. Apache Ignite Learning notes ( One ): Ignite Introduce 、 Deploy, install and REST/SQL Client side usage

    Apache Ignite Introduce Ignite What is it? ? Let's start with an official website about Ignite Description of : Ignite is memory-centric distributed database, cachi ...

  5. Apache Lucene Learning notes

    Hadoop summary Apache lucene: The world's first open source full text search engine toolkit Complete query engine and search engine Part of the text analysis engine Developers build a complete full-text search engine on this basis The following is a reprint of :http://www ...

  6. ofbiz Learning notes 01-- Multi table associated query

    No matter what project you do , We will definitely use multi table association to query data , We know from the Internet that ofbiz There are three methods of multi table Association query Achieve one :Screem.xml  Medium  section  in , Add  <action>,  Add  get-re ...

  7. Apache Hadoop Study note 1

    Official website :http://hadoop.apache.org/ 1 What is? Hadoop? ApacheHadoop The project developed for reliable , Open source software for scalable distributed computing . Apache Hadoop Software library is a ...

  8. Activiti Workflow learning notes ( Four )—— The establishment and application principle of responsibility chain pattern in workflow engine

    original / Zhu Jiqian This paper needs the basis of the responsibility chain model , It is mainly divided into three parts : One . Simply understand the concept of chain of responsibility model Two .Activiti The establishment of responsibility chain model in workflow 3、 ... and .Activiti The application of responsibility chain model in workflow One . Simple understanding of responsibility ...

  9. MongoDB Learning notes ~MongoDB Value objects in entities

    Back to directory Be careful , The value object here refers to MongoDB In entity class , Not at all DDD Value object in , however , The two are also connected , It's a complement to the class , I have no value of being , And in the value object , It doesn't need to have a primary key Id Of , This is related to DDD also ...

Random recommendation

  1. Java Interview basic concept summary

    What are the advantages of object-oriented software development ? answer : Develop modularity , Easier to maintain and modify : Code can be reused : Enhance the reliability of the code . Flexibility and comprehensibility . The definition of polymorphism ? answer : Polymorphism is the ability of programming languages to show the same interface to different underlying data types . ...

  2. unity3d Editor —— The inspector section ( One )

    Studying recently unity Editor ,so, Let's summarize the record . Here are some simple unity3d How to use the inspector section . using UnityEngine; using System.Collections; ...

  3. javascript And jquery For each p Label increase onclick Method

    <script type="text/javascript"> window.onload=function(){ var items=document.getElem ...

  4. connection.getResponseCode()!=200

    android It's not executed in network programming connection.getResponseCode()!=200 1. When testing on a real machine , The computer and mobile phone must be connected with a local area network . 2. You have to start a new thread , Don't access it in the main thread . ...

  5. POJ Topic classification ( turn )

    initial stage : One . Basic algorithm :     (1) enumeration . (poj1753,poj2965)     (2) greedy (poj1328,poj2109,poj2586)     (3) Recursion and divide and conquer .     (4) Recurrence . ...

  6. New Tang M0 ISP Download points

    http://blog.csdn.net/rejoice818/article/details/7736029 One . Be careful : On the official CD “Software Utilities” Under the table of contents , Can find ICP or ISP ...

  7. start-up php-fpm Times wrong

    [root@localhost ~]# /usr/local/php/sbin/php-fpm [06-Aug-2012 19:17:53] ALERT: [pool www] pm.min_spar ...

  8. Android Animation ScaleAnimation Apply specific explanation

    android Provided in 4 Chinese animation : AlphaAnimation Transparency animation effects ScaleAnimation Zoom animation TranslateAnimation Displacement animation effect RotateAnimat ...

  9. keyword -super

    super Can be understood as pointing to their own super ( Father ) A pointer to a class object , And this superclass refers to the nearest parent class . class BaseAction { String name; int age; void value( ...

  10. day 7-9 IO Model

    One , Synchronous and asynchronous , Blocking and non-blocking Sync (synchronous): When a process performs a task , The other process has to wait for its execution to finish , In order to proceed # So called synchronization , When a function call is issued , Before we get results , The call will ...