Composite entity pattern: Difference between revisions

Content deleted Content added
m Consequences: Minor typos
m Typo/general fixes, replaced: persistance → persistence, typo(s) fixed: comtainer → container using AWB
Line 5:
 
[[File:Composte_entity_pattern_class_diagram.png|center|Composite entity pattern class diagram]]
 
 
[[File:Composite_entity_pattern_sequence_diagram.png|center|Composite entity pattern sequence diagram]]
 
===Composite entity component===
Composite entity is the coarse-grained entity bean which may be the coarse-grained object, or may contain a reference to the coarse-grained object.<ref name=":o_cjp"/>
 
===Coarse-grained object===
A coarse-grained object is an object with its own life cycyle manages its own relationships to other objects. It can an object contained in the composite entity, or, composite entity itself can be the coarse-grained object which holds dependent objects.<ref name=":o_cjp"/>
 
===Dependent objects===
It is an object, which can contain other dependent objects (there may be a tree of objects within the composite entity), that depends on the coarse-grained object and has its life cycle managed by the coarse-grained object.<ref name=":o_cjp"/>
Line 17 ⟶ 19:
==Consequences==
According to Oracle description of the pattern, consequences include eliminating inter-entity relationships, improving manageability by reducing entity beans, improving network performance, reducing database schema dependency, increasing object granularity, facilitating composite transfer object creation and overhead of multi-level dependent object graphs.<ref name=":o_cjp"/>
 
===Drawbacks===
The fatal drawback is the requirement of bean-managed persistent (BMP) [[JavaBeans|bean]]. This involves more work for developers, and create some problems as follows:
* materializing all the data in a coarse-grained entity whenever it is accessed, is unacceptably expensive
* In [[Java (programming language)|Java]], implementation of the ejbStore() method needs to be smart enough to avoid issuing all the updates required to persist the entire state of the object, unless the data has changed in all the persistent objects.
Composite entity pattern can only be implemented using BMP or by adding more hand-coded persistence logic to comtainercontainer managed persistancepersistence (CMP) [[JavaBeans|beans]]. These both approaches reduce the maintainability.<ref name=":eojdad">{{Cite book|title = Expert One-on-One J2EE Design and Development|last = Johnson|first = R. |publisher = Wiley Publishing, Inc|year = 2003|___location = Indianapolis|volume = |pages = 290}}</ref>
 
==Sample code==
Line 56 ⟶ 59:
public Collection skillSets;
 
...
 
private EntityContext context;
Line 269 ⟶ 272:
}
 
</source><ref name=":o_cjp"/>
 
</source><ref name=":o_cjp"/>
==See also==
* [[Data transfer object]]
Line 278 ⟶ 281:
 
{{Design Patterns patterns}}
 
[[Category:Software design patterns]]