001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.completex.objective.persistency.examples.ex003a.cpxpos;
004:
005: import com.completex.objective.components.persistency.*;
006: import java.sql.SQLException;
007: import java.util.List;
008: import java.util.ArrayList;
009:
010: public class CpxOrderPO
011: extends
012: com.completex.objective.persistency.examples.ex003a.domain.Order
013: implements ICpxOrder, java.io.Externalizable {
014:
015: public CpxOrderPO() {
016: }
017:
018: public CpxOrderPO(Long orderId) {
019: super (orderId);
020: }
021:
022: //
023: // Complex object part:
024: //
025: public static final String CPX_CHILD_ORDER_ITEM = "orderItem";
026: protected static final com.completex.objective.components.persistency.type.TracingArrayListCollectionFactory ORDER_ITEM_COLLECTION_FACTORY = new com.completex.objective.components.persistency.type.TracingArrayListCollectionFactory();
027: private List orderItems;
028:
029: protected static final int CPX_INDEX_ORDER_ITEM = 0;
030:
031: public boolean complex() {
032: return true;
033: }
034:
035: protected Link[] links(QueryFactory queryFactory) {
036: try {
037: Link[] links = new Link[1];
038: Query query;
039: Link link;
040: query = queryFactory
041: .newQuery((PersistentObject) cpxFactoryOrderItem());
042: link = new ChainedLink(
043: query,
044: new int[] { CpxOrderPO.ICOL_ORDER_ID, },
045: new int[] { com.completex.objective.persistency.examples.ex003a.domain.OrderItem.ICOL_ORDER_ID, },
046: CPX_CHILD_ORDER_ITEM);
047: link.setLazyRetrieval(false);
048: link.setCascadeInsert(true);
049: link.setCascadeUpdate(true);
050: link.setCascadeDelete(true);
051: link.setInsertBeforeParent(false);
052: query
053: .setMultipleResultFactory(ORDER_ITEM_COLLECTION_FACTORY);
054: links[CPX_INDEX_ORDER_ITEM] = link;
055: return links;
056: } catch (Exception e) {
057: throw new OdalRuntimePersistencyException(e);
058: }
059: }
060:
061: /**
062: *
063: * @return Child factory
064: */
065: protected com.completex.objective.persistency.examples.ex003a.domain.OrderItem cpxFactoryOrderItem() {
066: return new com.completex.objective.persistency.examples.ex003a.domain.OrderItem();
067: }
068:
069: public List getOrderItems() {
070: List value = (List) getChildObject(CPX_CHILD_ORDER_ITEM,
071: this .orderItems);
072: return (this .orderItems = _ridOfOrderItemsNull(value));
073: }
074:
075: public List _getOrderItems() {
076: List value = (List) getChildObjectStraight(
077: CPX_CHILD_ORDER_ITEM, this .orderItems);
078: return (this .orderItems = _ridOfOrderItemsNull(value));
079: }
080:
081: public void setOrderItems(List orderItems) {
082: this .orderItems = (List) setChildObjectSafe(
083: CPX_CHILD_ORDER_ITEM, orderItems);
084: }
085:
086: public List addOrderItems() {
087: List orderItems = (List) ORDER_ITEM_COLLECTION_FACTORY
088: .newCollection();
089: java.util.Collection collection = orderItems;
090: handleAddCollection(collection);
091: setOrderItems(orderItems);
092: return this .orderItems;
093: }
094:
095: protected List _ridOfOrderItemsNull(List value) {
096: if (value == null) {
097: value = lazyOrderItems();
098: }
099: return value;
100: }
101:
102: public boolean addOrderItem(
103: com.completex.objective.persistency.examples.ex003a.pos.IOrderItem orderItem) {
104: return lazyOrderItems().add(orderItem);
105: }
106:
107: protected List lazyOrderItems() {
108: if (this .orderItems == null) {
109: addOrderItems();
110: }
111: return this .orderItems;
112: }
113:
114: public boolean removeOrderItem(
115: com.completex.objective.persistency.examples.ex003a.pos.IOrderItem orderItem) {
116: if (this .orderItems == null) {
117: return false;
118: }
119: return this .orderItems.remove(orderItem);
120: }
121:
122: protected void doUnflatten() {
123: unflatten(toLink(), CPX_CHILD_ORDER_ITEM, orderItems);
124: }
125:
126: protected void doFlatten() {
127: flatten(orderItems);
128: }
129:
130: protected void doPreFlatten() {
131: _getOrderItems();
132: }
133:
134: //
135: // Compound object part:
136: //
137:
138: public boolean compound() {
139: return false;
140: }
141:
142: }
|