Dependency mapping Dependent Mapping

Source: Internet
Author: User

To have a class perform a DB mapping for its subclasses (a generic idea)

  • Some objects will certainly appear in the context of another object.
  • At this point, a mapping of the first object is performed using the mapper of another object to simplify the mapping process.
  • Operating mechanism
      • When DB is persisted, the dependency class relies on the owner class. Each dependent can have only one owner.
      • Activity record and row data entry
        • The mapping code for the dependency class is written in the owner.
      • Data mapper
        • A mapper class that does not have a dependency, which completes the dependency mapping code in the owner's mapper.
      • Table Data Entry
        • There is no dependency class at all. Complete the processing of the dependents in the owner.
      • Typically, when an owner is loaded, the dependent dependents are loaded. Lazy loading is used when the associated load is expensive.
      • Dependent person
        • No domain is identified. It does not have to be stored in an identity map.
        • cannot be loaded by the lookup method by ID . Thus there is no finder for the relying person, but only the owner's finder.
        • One dependency may also be the owner of another dependency. At this point, the master owner controls the entire dependency hierarchy.
      • In a Memory object, only the owner and the dependent of the relying person can have a reference to the relying person.
      • In DB, other tables cannot have foreign keys to the dependency table, except for the owner table and the table that owns the owner.
      • In UML, a combination is used to represent the relationship between the two.
      • Update
        • By the owner to complete the write and save of the dependent person.
        • Updates to the dependents can be done by deleting and inserting. The process does not need to be analyzed (directly removed first, then inserted).
      • However, tracking changes to the owner can become complex.
        • All changes to the dependent person are marked by the owner.
        • Scenario: Keep the dependent person constant.
          • In this way, the change to the dependent person is removed first and then inserted into a new dependent person process.
          • This scenario simplifies the DB mapping, but simultaneously coupled the memory model and database mappings.
  • Use time
    • When an object is preparing another object reference, it is generally when an object has a corresponding set of dependents, while the relying person does not have a back pointer.
    • at the same time, it simplifies the retention management of objects if the object itself does not require an ID.
    • prerequisites to be met
      • only one owner per dependent
      • cannot exist outside the owner of an object that has a reference to the relying person.
    • It is a technique that simplifies db mapping and makes it impossible to reference dependents externally. The discovery mechanism that causes the root owner is complex.
    • do not use a unit of work when working with it. The
      • unit of work cannot control the dependents. The result is an orphaned, non-tracked dependency.
Related Article

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.