001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.completex.objective.persistency.examples.ex003a.pos;
004:
005: import com.completex.objective.components.persistency.key.impl.DefaultNaturalKeyFactory;
006: import java.util.Date;
007: import java.util.HashMap;
008: import java.util.Map;
009: import java.io.InputStream;
010: import java.math.BigDecimal;
011: import java.math.BigInteger;
012: import java.sql.Clob;
013: import java.sql.Blob;
014: import com.completex.objective.components.persistency.*;
015: import com.completex.objective.components.persistency.key.impl.DefaultNaturalKeyFactory;
016:
017: import com.completex.objective.persistency.examples.ex003a.pos.IOrderItem;
018: import java.util.Date;
019:
020: public class OrderItemPO extends PersistentObject implements
021: IOrderItem, java.io.Externalizable {
022: //
023: // Complex object related:
024: //
025:
026: //
027: private static Map registeredMasters;
028: private static Object lock = new Object();
029:
030: protected Object classLock() {
031: return lock;
032: }
033:
034: protected void instantiateRegisteredMasters() {
035: if (registeredMasters == null) {
036: synchronized (lock) {
037: if (registeredMasters == null) {
038: registeredMasters = new HashMap();
039: }
040: }
041: }
042: }
043:
044: protected Map registeredMasters() {
045: return registeredMasters;
046: }
047:
048: //
049: //
050: //
051:
052: public static final String TABLE_ORDER_ITEM = "ORDER_ITEM";
053:
054: public OrderItemPO() {
055: super (new Record(table));
056: }
057:
058: public OrderItemPO(Long orderItemId) {
059: this ();
060: setOrderItemId(orderItemId);
061: }
062:
063: public static final String COL_ORDER_ITEM_ID = "ORDER_ITEM_ID";
064: public static final String TCOL_ORDER_ITEM_ID = "ORDER_ITEM.ORDER_ITEM_ID";
065: public static final int ICOL_ORDER_ITEM_ID = 0;
066: public static final int JDBC_TYPE_ORDER_ITEM_ID = -5;
067:
068: public static final String COL_ORDER_ID = "ORDER_ID";
069: public static final String TCOL_ORDER_ID = "ORDER_ITEM.ORDER_ID";
070: public static final int ICOL_ORDER_ID = 1;
071: public static final int JDBC_TYPE_ORDER_ID = -5;
072:
073: public static final String COL_PRODUCT_ID = "PRODUCT_ID";
074: public static final String TCOL_PRODUCT_ID = "ORDER_ITEM.PRODUCT_ID";
075: public static final int ICOL_PRODUCT_ID = 2;
076: public static final int JDBC_TYPE_PRODUCT_ID = -5;
077:
078: public static final String COL_QUANTITY = "QUANTITY";
079: public static final String TCOL_QUANTITY = "ORDER_ITEM.QUANTITY";
080: public static final int ICOL_QUANTITY = 3;
081: public static final int JDBC_TYPE_QUANTITY = -5;
082:
083: public static final String COL_STATE = "STATE";
084: public static final String TCOL_STATE = "ORDER_ITEM.STATE";
085: public static final int ICOL_STATE = 4;
086: public static final int JDBC_TYPE_STATE = 12;
087:
088: public static final String COL_LAST_UPDATED = "LAST_UPDATED";
089: public static final String TCOL_LAST_UPDATED = "ORDER_ITEM.LAST_UPDATED";
090: public static final int ICOL_LAST_UPDATED = 5;
091: public static final int JDBC_TYPE_LAST_UPDATED = 91;
092:
093: public static final String COL_CREATION_DATE = "CREATION_DATE";
094: public static final String TCOL_CREATION_DATE = "ORDER_ITEM.CREATION_DATE";
095: public static final int ICOL_CREATION_DATE = 6;
096: public static final int JDBC_TYPE_CREATION_DATE = 91;
097:
098: private static final MetaTable table = new MetaTable("ORDER_ITEM",
099: "ORDER_ITEM", 7, 1);
100:
101: static {
102: table.setStaticFinal(true);
103: //
104: // Meta Foreign Keys:
105: //
106: table.addToForeignKey("CUSTOMER_ORDER", new ForeignKeyEntry(
107: "ORDER_ID", "ORDER_ID"));
108: //
109: // Meta Natural Key:
110: //
111: // naturalKey has no context
112:
113: //
114: // Meta Columns:
115: //
116:
117: final MetaColumn metaOrderItemId = new MetaColumn(
118: ICOL_ORDER_ITEM_ID, "ORDER_ITEM_ID", "ORDER_ITEM_ID",
119: table);
120: metaOrderItemId.setPrimaryKey(true);
121: metaOrderItemId.setRequired(true);
122: metaOrderItemId.setOptimisticLock(false);
123: metaOrderItemId.setType(ColumnType.LONG);
124: metaOrderItemId.setColumnSize(0);
125: metaOrderItemId.setRemarks("");
126: metaOrderItemId.setDecimalDigits(0);
127: metaOrderItemId.setAutoGenerated(true);
128: metaOrderItemId.setAutoIncrement(false);
129: metaOrderItemId.setJdbcType(-5);
130: metaOrderItemId
131: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
132: {
133: HashMap staticAttributes = new HashMap();
134: staticAttributes.put("name", "ORDER_ITEM_SEQ");
135: metaOrderItemId
136: .setGeneratorStaticAttributes(staticAttributes);
137: }
138: metaOrderItemId.initializeKeyGenerator();
139: table.addToPrimaryKey(new Integer(ICOL_ORDER_ITEM_ID));
140: table.addColumn(metaOrderItemId);
141:
142: final MetaColumn metaOrderId = new MetaColumn(ICOL_ORDER_ID,
143: "ORDER_ID", "ORDER_ID", table);
144: metaOrderId.setPrimaryKey(false);
145: metaOrderId.setRequired(true);
146: metaOrderId.setOptimisticLock(false);
147: metaOrderId.setType(ColumnType.LONG);
148: metaOrderId.setColumnSize(0);
149: metaOrderId.setRemarks("");
150: metaOrderId.setDecimalDigits(0);
151: metaOrderId.setAutoGenerated(false);
152: metaOrderId.setAutoIncrement(false);
153: metaOrderId.setJdbcType(-5);
154: table.addColumn(metaOrderId);
155:
156: final MetaColumn metaProductId = new MetaColumn(
157: ICOL_PRODUCT_ID, "PRODUCT_ID", "PRODUCT_ID", table);
158: metaProductId.setPrimaryKey(false);
159: metaProductId.setRequired(true);
160: metaProductId.setOptimisticLock(false);
161: metaProductId.setType(ColumnType.LONG);
162: metaProductId.setColumnSize(0);
163: metaProductId.setRemarks("");
164: metaProductId.setDecimalDigits(0);
165: metaProductId.setAutoGenerated(false);
166: metaProductId.setAutoIncrement(false);
167: metaProductId.setJdbcType(-5);
168: table.addColumn(metaProductId);
169:
170: final MetaColumn metaQuantity = new MetaColumn(ICOL_QUANTITY,
171: "QUANTITY", "QUANTITY", table);
172: metaQuantity.setPrimaryKey(false);
173: metaQuantity.setRequired(false);
174: metaQuantity.setOptimisticLock(false);
175: metaQuantity.setType(ColumnType.LONG);
176: metaQuantity.setColumnSize(0);
177: metaQuantity.setRemarks("");
178: metaQuantity.setDecimalDigits(0);
179: metaQuantity.setAutoGenerated(false);
180: metaQuantity.setAutoIncrement(false);
181: metaQuantity.setJdbcType(-5);
182: table.addColumn(metaQuantity);
183:
184: final MetaColumn metaState = new MetaColumn(ICOL_STATE,
185: "STATE", "STATE", table);
186: metaState.setPrimaryKey(false);
187: metaState.setRequired(true);
188: metaState.setOptimisticLock(false);
189: metaState.setType(ColumnType.STRING);
190: metaState.setColumnSize(40);
191: metaState.setRemarks("");
192: metaState.setDecimalDigits(0);
193: metaState.setAutoGenerated(false);
194: metaState.setAutoIncrement(false);
195: metaState.setJdbcType(12);
196: table.addColumn(metaState);
197:
198: final MetaColumn metaLastUpdated = new MetaColumn(
199: ICOL_LAST_UPDATED, "LAST_UPDATED", "LAST_UPDATED",
200: table);
201: metaLastUpdated.setPrimaryKey(false);
202: metaLastUpdated.setRequired(false);
203: metaLastUpdated.setOptimisticLock(false);
204: metaLastUpdated.setType(ColumnType.DATE);
205: metaLastUpdated.setColumnSize(0);
206: metaLastUpdated.setRemarks("");
207: metaLastUpdated.setDecimalDigits(0);
208: metaLastUpdated.setAutoGenerated(true);
209: metaLastUpdated.setAutoIncrement(false);
210: metaLastUpdated.setJdbcType(91);
211: metaLastUpdated
212: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
213: metaLastUpdated.initializeKeyGenerator();
214: table.addColumn(metaLastUpdated);
215:
216: final MetaColumn metaCreationDate = new MetaColumn(
217: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
218: table);
219: metaCreationDate.setPrimaryKey(false);
220: metaCreationDate.setRequired(false);
221: metaCreationDate.setOptimisticLock(false);
222: metaCreationDate.setType(ColumnType.DATE);
223: metaCreationDate.setColumnSize(0);
224: metaCreationDate.setRemarks("");
225: metaCreationDate.setDecimalDigits(0);
226: metaCreationDate.setAutoGenerated(true);
227: metaCreationDate.setAutoIncrement(false);
228: metaCreationDate.setJdbcType(91);
229: metaCreationDate
230: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
231: metaCreationDate.initializeKeyGenerator();
232: table.addColumn(metaCreationDate);
233:
234: }
235:
236: private Long orderItemId;
237: private Long orderId;
238: private Long productId;
239: private Long quantity;
240: private String state;
241: private Date lastUpdated;
242: private Date creationDate;
243:
244: //
245: // orderItemId:
246: //
247: public Long getOrderItemId() {
248: return this .orderItemId;
249: }
250:
251: public void setOrderItemId(Long orderItemId) {
252: if (record2().setObject(ICOL_ORDER_ITEM_ID, orderItemId)) {
253: this .orderItemId = orderItemId;
254: }
255: }
256:
257: public boolean izNullOrderItemId() {
258: return record2().getObject(ICOL_ORDER_ITEM_ID) == null;
259: }
260:
261: public void setNullOrderItemId() {
262: if (record2().setObject(ICOL_ORDER_ITEM_ID, null)) {
263: this .orderItemId = null;
264: }
265: }
266:
267: //
268: // orderId:
269: //
270: public Long getOrderId() {
271: return this .orderId;
272: }
273:
274: public void setOrderId(Long orderId) {
275: if (record2().setObject(ICOL_ORDER_ID, orderId)) {
276: this .orderId = orderId;
277: }
278: }
279:
280: public boolean izNullOrderId() {
281: return record2().getObject(ICOL_ORDER_ID) == null;
282: }
283:
284: public void setNullOrderId() {
285: if (record2().setObject(ICOL_ORDER_ID, null)) {
286: this .orderId = null;
287: }
288: }
289:
290: //
291: // productId:
292: //
293: public Long getProductId() {
294: return this .productId;
295: }
296:
297: public void setProductId(Long productId) {
298: if (record2().setObject(ICOL_PRODUCT_ID, productId)) {
299: this .productId = productId;
300: }
301: }
302:
303: public boolean izNullProductId() {
304: return record2().getObject(ICOL_PRODUCT_ID) == null;
305: }
306:
307: public void setNullProductId() {
308: if (record2().setObject(ICOL_PRODUCT_ID, null)) {
309: this .productId = null;
310: }
311: }
312:
313: //
314: // quantity:
315: //
316: public Long getQuantity() {
317: return this .quantity;
318: }
319:
320: public void setQuantity(Long quantity) {
321: if (record2().setObject(ICOL_QUANTITY, quantity)) {
322: this .quantity = quantity;
323: }
324: }
325:
326: public boolean izNullQuantity() {
327: return record2().getObject(ICOL_QUANTITY) == null;
328: }
329:
330: public void setNullQuantity() {
331: if (record2().setObject(ICOL_QUANTITY, null)) {
332: this .quantity = null;
333: }
334: }
335:
336: //
337: // state:
338: //
339: public String getState() {
340: return this .state;
341: }
342:
343: public void setState(String state) {
344: if (record2().setObject(ICOL_STATE, state)) {
345: this .state = state;
346: }
347: }
348:
349: public boolean izNullState() {
350: return record2().getObject(ICOL_STATE) == null;
351: }
352:
353: public void setNullState() {
354: if (record2().setObject(ICOL_STATE, null)) {
355: this .state = null;
356: }
357: }
358:
359: //
360: // lastUpdated:
361: //
362: public Date getLastUpdated() {
363: return this .lastUpdated;
364: }
365:
366: public void setLastUpdated(Date lastUpdated) {
367: if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
368: this .lastUpdated = lastUpdated;
369: }
370: }
371:
372: public boolean izNullLastUpdated() {
373: return record2().getObject(ICOL_LAST_UPDATED) == null;
374: }
375:
376: public void setNullLastUpdated() {
377: if (record2().setObject(ICOL_LAST_UPDATED, null)) {
378: this .lastUpdated = null;
379: }
380: }
381:
382: //
383: // creationDate:
384: //
385: public Date getCreationDate() {
386: return this .creationDate;
387: }
388:
389: public void setCreationDate(Date creationDate) {
390: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
391: this .creationDate = creationDate;
392: }
393: }
394:
395: public boolean izNullCreationDate() {
396: return record2().getObject(ICOL_CREATION_DATE) == null;
397: }
398:
399: public void setNullCreationDate() {
400: if (record2().setObject(ICOL_CREATION_DATE, null)) {
401: this .creationDate = null;
402: }
403: }
404:
405: public void toBeanFields() {
406: toBeanFields(this );
407: }
408:
409: public void toBeanFields(PersistentObject from) {
410: orderItemId = (Long) from.record2().getObject(
411: ICOL_ORDER_ITEM_ID);
412: orderId = (Long) from.record2().getObject(ICOL_ORDER_ID);
413: productId = (Long) from.record2().getObject(ICOL_PRODUCT_ID);
414: quantity = (Long) from.record2().getObject(ICOL_QUANTITY);
415: state = (String) from.record2().getObject(ICOL_STATE);
416: lastUpdated = (Date) from.record2()
417: .getObject(ICOL_LAST_UPDATED);
418: creationDate = (Date) from.record2().getObject(
419: ICOL_CREATION_DATE);
420: super .toBeanFields(from);
421: }
422:
423: public void fromBeanFields(PersistentObject persistentObject) {
424: OrderItemPO from = (OrderItemPO) persistentObject;
425: record2().getEntry(ICOL_ORDER_ITEM_ID).setUnmarkedValue(
426: from.orderItemId, from.orderItemId);
427: record2().getEntry(ICOL_ORDER_ID).setUnmarkedValue(
428: from.orderId, from.orderId);
429: record2().getEntry(ICOL_PRODUCT_ID).setUnmarkedValue(
430: from.productId, from.productId);
431: record2().getEntry(ICOL_QUANTITY).setUnmarkedValue(
432: from.quantity, from.quantity);
433: record2().getEntry(ICOL_STATE).setUnmarkedValue(from.state,
434: from.state);
435: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
436: from.lastUpdated, from.lastUpdated);
437: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
438: from.creationDate, from.creationDate);
439: super .fromBeanFieldsDataSaved(persistentObject);
440: }
441:
442: public String toString() {
443:
444: StringBuffer buffer = new StringBuffer();
445: buffer.append("{ " + "class = ").append(
446: this .getClass().getName()).append(" " + "table = ")
447: .append(TABLE_ORDER_ITEM).append(" columns = {");
448:
449: if (record() != null) {
450: buffer.append(COL_ORDER_ITEM_ID).append(" = ").append(
451: record().getObject(ICOL_ORDER_ITEM_ID)).append(" ");
452: buffer.append(COL_ORDER_ID).append(" = ").append(
453: record().getObject(ICOL_ORDER_ID)).append(" ");
454: buffer.append(COL_PRODUCT_ID).append(" = ").append(
455: record().getObject(ICOL_PRODUCT_ID)).append(" ");
456: buffer.append(COL_QUANTITY).append(" = ").append(
457: record().getObject(ICOL_QUANTITY)).append(" ");
458: buffer.append(COL_STATE).append(" = ").append(
459: record().getObject(ICOL_STATE)).append(" ");
460: buffer.append(COL_LAST_UPDATED).append(" = ").append(
461: record().getObject(ICOL_LAST_UPDATED)).append(" ");
462: buffer.append(COL_CREATION_DATE).append(" = ").append(
463: record().getObject(ICOL_CREATION_DATE)).append(" ");
464: } else {
465: buffer.append(COL_ORDER_ITEM_ID).append(" = ").append(
466: orderItemId).append(" ");
467: buffer.append(COL_ORDER_ID).append(" = ").append(orderId)
468: .append(" ");
469: buffer.append(COL_PRODUCT_ID).append(" = ").append(
470: productId).append(" ");
471: buffer.append(COL_QUANTITY).append(" = ").append(quantity)
472: .append(" ");
473: buffer.append(COL_STATE).append(" = ").append(state)
474: .append(" ");
475: buffer.append(COL_LAST_UPDATED).append(" = ").append(
476: lastUpdated).append(" ");
477: buffer.append(COL_CREATION_DATE).append(" = ").append(
478: creationDate).append(" ");
479: }
480: buffer.append("}}");
481: return buffer.toString();
482: }
483:
484: // naturalKey has no context
485:
486: /**
487: * Equals by Basic Peristent object fields (without children objects)
488: */
489: public boolean equalsBasic(Object value) {
490: if (this == value)
491: return true;
492: if (value == null || getClass() != value.getClass())
493: return false;
494:
495: OrderItemPO that = (OrderItemPO) value;
496:
497: if (orderItemId != null ? !orderItemId.equals(that.orderItemId)
498: : that.orderItemId != null)
499: return false;
500: if (orderId != null ? !orderId.equals(that.orderId)
501: : that.orderId != null)
502: return false;
503: if (productId != null ? !productId.equals(that.productId)
504: : that.productId != null)
505: return false;
506: if (quantity != null ? !quantity.equals(that.quantity)
507: : that.quantity != null)
508: return false;
509: if (state != null ? !state.equals(that.state)
510: : that.state != null)
511: return false;
512: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
513: : that.lastUpdated != null)
514: return false;
515: if (creationDate != null ? !creationDate
516: .equals(that.creationDate) : that.creationDate != null)
517: return false;
518: return true;
519: }
520:
521: /**
522: * hashCode by Basic Peristent object fields (without children objects)
523: */
524: public int hashCodeBasic() {
525: int result;
526: long temp;
527: result = (orderItemId != null ? orderItemId.hashCode() : 0);
528: result = 29 * result
529: + (orderId != null ? orderId.hashCode() : 0);
530: result = 29 * result
531: + (productId != null ? productId.hashCode() : 0);
532: result = 29 * result
533: + (quantity != null ? quantity.hashCode() : 0);
534: result = 29 * result + (state != null ? state.hashCode() : 0);
535: result = 29 * result
536: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
537: result = 29 * result
538: + (creationDate != null ? creationDate.hashCode() : 0);
539:
540: return result;
541: }
542: }
|