001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.completex.objective.persistency.examples.ex005.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 extends
011: com.completex.objective.persistency.examples.ex005.domain.Order
012: implements java.io.Externalizable {
013:
014: public CpxOrderPO() {
015: }
016:
017: public CpxOrderPO(Long orderId) {
018: super (orderId);
019: }
020:
021: //
022: // Complex object part:
023: //
024: public static final String CPX_CHILD_PARENT_ORDER = "parentOrder";
025: private com.completex.objective.persistency.examples.ex005.domain.CpxOrder parentOrder;
026: public static final String CPX_CHILD_ORDER_ITEM = "orderItem";
027: protected static final com.completex.objective.components.persistency.type.TracingArrayListCollectionFactory ORDER_ITEM_COLLECTION_FACTORY = new com.completex.objective.components.persistency.type.TracingArrayListCollectionFactory();
028: private List orderItems;
029:
030: protected static final int CPX_INDEX_PARENT_ORDER = 0;
031: protected static final int CPX_INDEX_ORDER_ITEM = 1;
032:
033: public boolean complex() {
034: return true;
035: }
036:
037: protected Link[] links(QueryFactory queryFactory) {
038: try {
039: Link[] links = new Link[2];
040: Query query;
041: Link link;
042: query = queryFactory
043: .newQuery((PersistentObject) cpxFactoryParentOrder());
044: link = new ChainedLink(
045: query,
046: new int[] { CpxOrderPO.ICOL_PARENT_ORDER_ID, },
047: new int[] { com.completex.objective.persistency.examples.ex005.domain.CpxOrder.ICOL_ORDER_ID, },
048: CPX_CHILD_PARENT_ORDER);
049: link.setLazyRetrieval(true);
050: link.setCascadeInsert(true);
051: link.setCascadeUpdate(true);
052: link.setCascadeDelete(true);
053: link.setInsertBeforeParent(true);
054: links[CPX_INDEX_PARENT_ORDER] = link;
055: query = queryFactory
056: .newQuery((PersistentObject) cpxFactoryOrderItem());
057: link = new ChainedLink(
058: query,
059: new int[] { CpxOrderPO.ICOL_ORDER_ID, },
060: new int[] { com.completex.objective.persistency.examples.ex005.domain.OrderItem.ICOL_ORDER_ID, },
061: CPX_CHILD_ORDER_ITEM);
062: link.setLazyRetrieval(true);
063: link.setCascadeInsert(true);
064: link.setCascadeUpdate(true);
065: link.setCascadeDelete(true);
066: link.setInsertBeforeParent(false);
067: query
068: .setMultipleResultFactory(ORDER_ITEM_COLLECTION_FACTORY);
069: links[CPX_INDEX_ORDER_ITEM] = link;
070: return links;
071: } catch (Exception e) {
072: throw new OdalRuntimePersistencyException(e);
073: }
074: }
075:
076: /**
077: *
078: * @return Child factory
079: */
080: protected com.completex.objective.persistency.examples.ex005.domain.CpxOrder cpxFactoryParentOrder() {
081: return new com.completex.objective.persistency.examples.ex005.domain.CpxOrder();
082: }
083:
084: public com.completex.objective.persistency.examples.ex005.domain.CpxOrder getParentOrder() {
085: return (this .parentOrder = (com.completex.objective.persistency.examples.ex005.domain.CpxOrder) getFirstChildObject(
086: CPX_CHILD_PARENT_ORDER, this .parentOrder));
087: }
088:
089: public com.completex.objective.persistency.examples.ex005.domain.CpxOrder _getParentOrder() {
090: return (this .parentOrder = (com.completex.objective.persistency.examples.ex005.domain.CpxOrder) getFirstChildObjectStraight(
091: CPX_CHILD_PARENT_ORDER, this .parentOrder));
092: }
093:
094: public void setParentOrder(
095: com.completex.objective.persistency.examples.ex005.domain.CpxOrder parentOrder) {
096: this .parentOrder = (com.completex.objective.persistency.examples.ex005.domain.CpxOrder) setChildObjectSafe(
097: CPX_CHILD_PARENT_ORDER, parentOrder);
098: }
099:
100: /**
101: *
102: * @return Child factory
103: */
104: protected com.completex.objective.persistency.examples.ex005.domain.OrderItem cpxFactoryOrderItem() {
105: return new com.completex.objective.persistency.examples.ex005.domain.OrderItem();
106: }
107:
108: public List getOrderItems() {
109: List value = (List) getChildObject(CPX_CHILD_ORDER_ITEM,
110: this .orderItems);
111: return (this .orderItems = _ridOfOrderItemsNull(value));
112: }
113:
114: public List _getOrderItems() {
115: List value = (List) getChildObjectStraight(
116: CPX_CHILD_ORDER_ITEM, this .orderItems);
117: return (this .orderItems = _ridOfOrderItemsNull(value));
118: }
119:
120: public void setOrderItems(List orderItems) {
121: this .orderItems = (List) setChildObjectSafe(
122: CPX_CHILD_ORDER_ITEM, orderItems);
123: }
124:
125: public List addOrderItems() {
126: List orderItems = (List) ORDER_ITEM_COLLECTION_FACTORY
127: .newCollection();
128: java.util.Collection collection = orderItems;
129: handleAddCollection(collection);
130: setOrderItems(orderItems);
131: return this .orderItems;
132: }
133:
134: protected List _ridOfOrderItemsNull(List value) {
135: if (value == null) {
136: value = lazyOrderItems();
137: }
138: return value;
139: }
140:
141: public boolean addOrderItem(
142: com.completex.objective.persistency.examples.ex005.domain.OrderItem orderItem) {
143: return lazyOrderItems().add(orderItem);
144: }
145:
146: protected List lazyOrderItems() {
147: if (this .orderItems == null) {
148: addOrderItems();
149: }
150: return this .orderItems;
151: }
152:
153: public boolean removeOrderItem(
154: com.completex.objective.persistency.examples.ex005.domain.OrderItem orderItem) {
155: if (this .orderItems == null) {
156: return false;
157: }
158: return this .orderItems.remove(orderItem);
159: }
160:
161: protected void doUnflatten() {
162: unflatten(toLink(), CPX_CHILD_PARENT_ORDER,
163: (PersistentObject) parentOrder);
164: unflatten(toLink(), CPX_CHILD_ORDER_ITEM, orderItems);
165: }
166:
167: protected void doFlatten() {
168: flatten((PersistentObject) parentOrder);
169: flatten(orderItems);
170: }
171:
172: protected void doPreFlatten() {
173: _getParentOrder();
174: _getOrderItems();
175: }
176:
177: //
178: // Compound object part:
179: //
180:
181: public boolean compound() {
182: return false;
183: }
184:
185: }
|