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.IProduct;
018: import java.math.BigDecimal;
019: import java.util.Date;
020:
021: public class ProductPO extends PersistentObject implements IProduct,
022: java.io.Externalizable {
023: //
024: // Complex object related:
025: //
026:
027: //
028: private static Map registeredMasters;
029: private static Object lock = new Object();
030:
031: protected Object classLock() {
032: return lock;
033: }
034:
035: protected void instantiateRegisteredMasters() {
036: if (registeredMasters == null) {
037: synchronized (lock) {
038: if (registeredMasters == null) {
039: registeredMasters = new HashMap();
040: }
041: }
042: }
043: }
044:
045: protected Map registeredMasters() {
046: return registeredMasters;
047: }
048:
049: //
050: //
051: //
052:
053: public static final String TABLE_PRODUCT = "PRODUCT";
054:
055: public ProductPO() {
056: super (new Record(table));
057: }
058:
059: public ProductPO(Long productId) {
060: this ();
061: setProductId(productId);
062: }
063:
064: public static final String COL_PRODUCT_ID = "PRODUCT_ID";
065: public static final String TCOL_PRODUCT_ID = "PRODUCT.PRODUCT_ID";
066: public static final int ICOL_PRODUCT_ID = 0;
067: public static final int JDBC_TYPE_PRODUCT_ID = -5;
068:
069: public static final String COL_NAME = "NAME";
070: public static final String TCOL_NAME = "PRODUCT.NAME";
071: public static final int ICOL_NAME = 1;
072: public static final int JDBC_TYPE_NAME = 12;
073:
074: public static final String COL_MAKE = "MAKE";
075: public static final String TCOL_MAKE = "PRODUCT.MAKE";
076: public static final int ICOL_MAKE = 2;
077: public static final int JDBC_TYPE_MAKE = 12;
078:
079: public static final String COL_MODEL = "MODEL";
080: public static final String TCOL_MODEL = "PRODUCT.MODEL";
081: public static final int ICOL_MODEL = 3;
082: public static final int JDBC_TYPE_MODEL = 12;
083:
084: public static final String COL_COLOUR = "COLOUR";
085: public static final String TCOL_COLOUR = "PRODUCT.COLOUR";
086: public static final int ICOL_COLOUR = 4;
087: public static final int JDBC_TYPE_COLOUR = 12;
088:
089: public static final String COL_PRICE = "PRICE";
090: public static final String TCOL_PRICE = "PRODUCT.PRICE";
091: public static final int ICOL_PRICE = 5;
092: public static final int JDBC_TYPE_PRICE = 3;
093:
094: public static final String COL_COST = "COST";
095: public static final String TCOL_COST = "PRODUCT.COST";
096: public static final int ICOL_COST = 6;
097: public static final int JDBC_TYPE_COST = 3;
098:
099: public static final String COL_LAST_UPDATED = "LAST_UPDATED";
100: public static final String TCOL_LAST_UPDATED = "PRODUCT.LAST_UPDATED";
101: public static final int ICOL_LAST_UPDATED = 7;
102: public static final int JDBC_TYPE_LAST_UPDATED = 91;
103:
104: public static final String COL_CREATION_DATE = "CREATION_DATE";
105: public static final String TCOL_CREATION_DATE = "PRODUCT.CREATION_DATE";
106: public static final int ICOL_CREATION_DATE = 8;
107: public static final int JDBC_TYPE_CREATION_DATE = 91;
108:
109: private static final MetaTable table = new MetaTable("PRODUCT",
110: "PRODUCT", 9, 1);
111:
112: static {
113: table.setStaticFinal(true);
114: //
115: // Meta Foreign Keys:
116: //
117: //
118: // Meta Natural Key:
119: //
120: // naturalKey has no context
121:
122: //
123: // Meta Columns:
124: //
125:
126: final MetaColumn metaProductId = new MetaColumn(
127: ICOL_PRODUCT_ID, "PRODUCT_ID", "PRODUCT_ID", table);
128: metaProductId.setPrimaryKey(true);
129: metaProductId.setRequired(true);
130: metaProductId.setOptimisticLock(false);
131: metaProductId.setType(ColumnType.LONG);
132: metaProductId.setColumnSize(0);
133: metaProductId.setRemarks("");
134: metaProductId.setDecimalDigits(0);
135: metaProductId.setAutoGenerated(true);
136: metaProductId.setAutoIncrement(false);
137: metaProductId.setJdbcType(-5);
138: metaProductId
139: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
140: {
141: HashMap staticAttributes = new HashMap();
142: staticAttributes.put("name", "PRODUCT_SEQ");
143: metaProductId
144: .setGeneratorStaticAttributes(staticAttributes);
145: }
146: metaProductId.initializeKeyGenerator();
147: table.addToPrimaryKey(new Integer(ICOL_PRODUCT_ID));
148: table.addColumn(metaProductId);
149:
150: final MetaColumn metaName = new MetaColumn(ICOL_NAME, "NAME",
151: "NAME", table);
152: metaName.setPrimaryKey(false);
153: metaName.setRequired(true);
154: metaName.setOptimisticLock(false);
155: metaName.setType(ColumnType.STRING);
156: metaName.setColumnSize(40);
157: metaName.setRemarks("");
158: metaName.setDecimalDigits(0);
159: metaName.setAutoGenerated(false);
160: metaName.setAutoIncrement(false);
161: metaName.setJdbcType(12);
162: table.addColumn(metaName);
163:
164: final MetaColumn metaMake = new MetaColumn(ICOL_MAKE, "MAKE",
165: "MAKE", table);
166: metaMake.setPrimaryKey(false);
167: metaMake.setRequired(true);
168: metaMake.setOptimisticLock(false);
169: metaMake.setType(ColumnType.STRING);
170: metaMake.setColumnSize(40);
171: metaMake.setRemarks("");
172: metaMake.setDecimalDigits(0);
173: metaMake.setAutoGenerated(false);
174: metaMake.setAutoIncrement(false);
175: metaMake.setJdbcType(12);
176: table.addColumn(metaMake);
177:
178: final MetaColumn metaModel = new MetaColumn(ICOL_MODEL,
179: "MODEL", "MODEL", table);
180: metaModel.setPrimaryKey(false);
181: metaModel.setRequired(true);
182: metaModel.setOptimisticLock(false);
183: metaModel.setType(ColumnType.STRING);
184: metaModel.setColumnSize(40);
185: metaModel.setRemarks("");
186: metaModel.setDecimalDigits(0);
187: metaModel.setAutoGenerated(false);
188: metaModel.setAutoIncrement(false);
189: metaModel.setJdbcType(12);
190: table.addColumn(metaModel);
191:
192: final MetaColumn metaColour = new MetaColumn(ICOL_COLOUR,
193: "COLOUR", "COLOUR", table);
194: metaColour.setPrimaryKey(false);
195: metaColour.setRequired(true);
196: metaColour.setOptimisticLock(false);
197: metaColour.setType(ColumnType.STRING);
198: metaColour.setColumnSize(40);
199: metaColour.setRemarks("");
200: metaColour.setDecimalDigits(0);
201: metaColour.setAutoGenerated(false);
202: metaColour.setAutoIncrement(false);
203: metaColour.setJdbcType(12);
204: table.addColumn(metaColour);
205:
206: final MetaColumn metaPrice = new MetaColumn(ICOL_PRICE,
207: "PRICE", "PRICE", table);
208: metaPrice.setPrimaryKey(false);
209: metaPrice.setRequired(true);
210: metaPrice.setOptimisticLock(false);
211: metaPrice.setType(ColumnType.BIGDECIMAL);
212: metaPrice.setColumnSize(40);
213: metaPrice.setRemarks("");
214: metaPrice.setDecimalDigits(2);
215: metaPrice.setAutoGenerated(false);
216: metaPrice.setAutoIncrement(false);
217: metaPrice.setJdbcType(3);
218: table.addColumn(metaPrice);
219:
220: final MetaColumn metaCost = new MetaColumn(ICOL_COST, "COST",
221: "COST", table);
222: metaCost.setPrimaryKey(false);
223: metaCost.setRequired(true);
224: metaCost.setOptimisticLock(false);
225: metaCost.setType(ColumnType.BIGDECIMAL);
226: metaCost.setColumnSize(40);
227: metaCost.setRemarks("");
228: metaCost.setDecimalDigits(2);
229: metaCost.setAutoGenerated(false);
230: metaCost.setAutoIncrement(false);
231: metaCost.setJdbcType(3);
232: table.addColumn(metaCost);
233:
234: final MetaColumn metaLastUpdated = new MetaColumn(
235: ICOL_LAST_UPDATED, "LAST_UPDATED", "LAST_UPDATED",
236: table);
237: metaLastUpdated.setPrimaryKey(false);
238: metaLastUpdated.setRequired(false);
239: metaLastUpdated.setOptimisticLock(false);
240: metaLastUpdated.setType(ColumnType.DATE);
241: metaLastUpdated.setColumnSize(0);
242: metaLastUpdated.setRemarks("");
243: metaLastUpdated.setDecimalDigits(0);
244: metaLastUpdated.setAutoGenerated(true);
245: metaLastUpdated.setAutoIncrement(false);
246: metaLastUpdated.setJdbcType(91);
247: metaLastUpdated
248: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
249: metaLastUpdated.initializeKeyGenerator();
250: table.addColumn(metaLastUpdated);
251:
252: final MetaColumn metaCreationDate = new MetaColumn(
253: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
254: table);
255: metaCreationDate.setPrimaryKey(false);
256: metaCreationDate.setRequired(false);
257: metaCreationDate.setOptimisticLock(false);
258: metaCreationDate.setType(ColumnType.DATE);
259: metaCreationDate.setColumnSize(0);
260: metaCreationDate.setRemarks("");
261: metaCreationDate.setDecimalDigits(0);
262: metaCreationDate.setAutoGenerated(true);
263: metaCreationDate.setAutoIncrement(false);
264: metaCreationDate.setJdbcType(91);
265: metaCreationDate
266: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
267: metaCreationDate.initializeKeyGenerator();
268: table.addColumn(metaCreationDate);
269:
270: }
271:
272: private Long productId;
273: private String name;
274: private String make;
275: private String model;
276: private String colour;
277: private BigDecimal price;
278: private BigDecimal cost;
279: private Date lastUpdated;
280: private Date creationDate;
281:
282: //
283: // productId:
284: //
285: public Long getProductId() {
286: return this .productId;
287: }
288:
289: public void setProductId(Long productId) {
290: if (record2().setObject(ICOL_PRODUCT_ID, productId)) {
291: this .productId = productId;
292: }
293: }
294:
295: public boolean izNullProductId() {
296: return record2().getObject(ICOL_PRODUCT_ID) == null;
297: }
298:
299: public void setNullProductId() {
300: if (record2().setObject(ICOL_PRODUCT_ID, null)) {
301: this .productId = null;
302: }
303: }
304:
305: //
306: // name:
307: //
308: public String getName() {
309: return this .name;
310: }
311:
312: public void setName(String name) {
313: if (record2().setObject(ICOL_NAME, name)) {
314: this .name = name;
315: }
316: }
317:
318: public boolean izNullName() {
319: return record2().getObject(ICOL_NAME) == null;
320: }
321:
322: public void setNullName() {
323: if (record2().setObject(ICOL_NAME, null)) {
324: this .name = null;
325: }
326: }
327:
328: //
329: // make:
330: //
331: public String getMake() {
332: return this .make;
333: }
334:
335: public void setMake(String make) {
336: if (record2().setObject(ICOL_MAKE, make)) {
337: this .make = make;
338: }
339: }
340:
341: public boolean izNullMake() {
342: return record2().getObject(ICOL_MAKE) == null;
343: }
344:
345: public void setNullMake() {
346: if (record2().setObject(ICOL_MAKE, null)) {
347: this .make = null;
348: }
349: }
350:
351: //
352: // model:
353: //
354: public String getModel() {
355: return this .model;
356: }
357:
358: public void setModel(String model) {
359: if (record2().setObject(ICOL_MODEL, model)) {
360: this .model = model;
361: }
362: }
363:
364: public boolean izNullModel() {
365: return record2().getObject(ICOL_MODEL) == null;
366: }
367:
368: public void setNullModel() {
369: if (record2().setObject(ICOL_MODEL, null)) {
370: this .model = null;
371: }
372: }
373:
374: //
375: // colour:
376: //
377: public String getColour() {
378: return this .colour;
379: }
380:
381: public void setColour(String colour) {
382: if (record2().setObject(ICOL_COLOUR, colour)) {
383: this .colour = colour;
384: }
385: }
386:
387: public boolean izNullColour() {
388: return record2().getObject(ICOL_COLOUR) == null;
389: }
390:
391: public void setNullColour() {
392: if (record2().setObject(ICOL_COLOUR, null)) {
393: this .colour = null;
394: }
395: }
396:
397: //
398: // price:
399: //
400: public BigDecimal getPrice() {
401: return this .price;
402: }
403:
404: public void setPrice(BigDecimal price) {
405: if (record2().setObject(ICOL_PRICE, price)) {
406: this .price = price;
407: }
408: }
409:
410: public boolean izNullPrice() {
411: return record2().getObject(ICOL_PRICE) == null;
412: }
413:
414: public void setNullPrice() {
415: if (record2().setObject(ICOL_PRICE, null)) {
416: this .price = null;
417: }
418: }
419:
420: //
421: // cost:
422: //
423: public BigDecimal getCost() {
424: return this .cost;
425: }
426:
427: public void setCost(BigDecimal cost) {
428: if (record2().setObject(ICOL_COST, cost)) {
429: this .cost = cost;
430: }
431: }
432:
433: public boolean izNullCost() {
434: return record2().getObject(ICOL_COST) == null;
435: }
436:
437: public void setNullCost() {
438: if (record2().setObject(ICOL_COST, null)) {
439: this .cost = null;
440: }
441: }
442:
443: //
444: // lastUpdated:
445: //
446: public Date getLastUpdated() {
447: return this .lastUpdated;
448: }
449:
450: public void setLastUpdated(Date lastUpdated) {
451: if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
452: this .lastUpdated = lastUpdated;
453: }
454: }
455:
456: public boolean izNullLastUpdated() {
457: return record2().getObject(ICOL_LAST_UPDATED) == null;
458: }
459:
460: public void setNullLastUpdated() {
461: if (record2().setObject(ICOL_LAST_UPDATED, null)) {
462: this .lastUpdated = null;
463: }
464: }
465:
466: //
467: // creationDate:
468: //
469: public Date getCreationDate() {
470: return this .creationDate;
471: }
472:
473: public void setCreationDate(Date creationDate) {
474: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
475: this .creationDate = creationDate;
476: }
477: }
478:
479: public boolean izNullCreationDate() {
480: return record2().getObject(ICOL_CREATION_DATE) == null;
481: }
482:
483: public void setNullCreationDate() {
484: if (record2().setObject(ICOL_CREATION_DATE, null)) {
485: this .creationDate = null;
486: }
487: }
488:
489: public void toBeanFields() {
490: toBeanFields(this );
491: }
492:
493: public void toBeanFields(PersistentObject from) {
494: productId = (Long) from.record2().getObject(ICOL_PRODUCT_ID);
495: name = (String) from.record2().getObject(ICOL_NAME);
496: make = (String) from.record2().getObject(ICOL_MAKE);
497: model = (String) from.record2().getObject(ICOL_MODEL);
498: colour = (String) from.record2().getObject(ICOL_COLOUR);
499: price = (BigDecimal) from.record2().getObject(ICOL_PRICE);
500: cost = (BigDecimal) from.record2().getObject(ICOL_COST);
501: lastUpdated = (Date) from.record2()
502: .getObject(ICOL_LAST_UPDATED);
503: creationDate = (Date) from.record2().getObject(
504: ICOL_CREATION_DATE);
505: super .toBeanFields(from);
506: }
507:
508: public void fromBeanFields(PersistentObject persistentObject) {
509: ProductPO from = (ProductPO) persistentObject;
510: record2().getEntry(ICOL_PRODUCT_ID).setUnmarkedValue(
511: from.productId, from.productId);
512: record2().getEntry(ICOL_NAME).setUnmarkedValue(from.name,
513: from.name);
514: record2().getEntry(ICOL_MAKE).setUnmarkedValue(from.make,
515: from.make);
516: record2().getEntry(ICOL_MODEL).setUnmarkedValue(from.model,
517: from.model);
518: record2().getEntry(ICOL_COLOUR).setUnmarkedValue(from.colour,
519: from.colour);
520: record2().getEntry(ICOL_PRICE).setUnmarkedValue(from.price,
521: from.price);
522: record2().getEntry(ICOL_COST).setUnmarkedValue(from.cost,
523: from.cost);
524: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
525: from.lastUpdated, from.lastUpdated);
526: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
527: from.creationDate, from.creationDate);
528: super .fromBeanFieldsDataSaved(persistentObject);
529: }
530:
531: public String toString() {
532:
533: StringBuffer buffer = new StringBuffer();
534: buffer.append("{ " + "class = ").append(
535: this .getClass().getName()).append(" " + "table = ")
536: .append(TABLE_PRODUCT).append(" columns = {");
537:
538: if (record() != null) {
539: buffer.append(COL_PRODUCT_ID).append(" = ").append(
540: record().getObject(ICOL_PRODUCT_ID)).append(" ");
541: buffer.append(COL_NAME).append(" = ").append(
542: record().getObject(ICOL_NAME)).append(" ");
543: buffer.append(COL_MAKE).append(" = ").append(
544: record().getObject(ICOL_MAKE)).append(" ");
545: buffer.append(COL_MODEL).append(" = ").append(
546: record().getObject(ICOL_MODEL)).append(" ");
547: buffer.append(COL_COLOUR).append(" = ").append(
548: record().getObject(ICOL_COLOUR)).append(" ");
549: buffer.append(COL_PRICE).append(" = ").append(
550: record().getObject(ICOL_PRICE)).append(" ");
551: buffer.append(COL_COST).append(" = ").append(
552: record().getObject(ICOL_COST)).append(" ");
553: buffer.append(COL_LAST_UPDATED).append(" = ").append(
554: record().getObject(ICOL_LAST_UPDATED)).append(" ");
555: buffer.append(COL_CREATION_DATE).append(" = ").append(
556: record().getObject(ICOL_CREATION_DATE)).append(" ");
557: } else {
558: buffer.append(COL_PRODUCT_ID).append(" = ").append(
559: productId).append(" ");
560: buffer.append(COL_NAME).append(" = ").append(name).append(
561: " ");
562: buffer.append(COL_MAKE).append(" = ").append(make).append(
563: " ");
564: buffer.append(COL_MODEL).append(" = ").append(model)
565: .append(" ");
566: buffer.append(COL_COLOUR).append(" = ").append(colour)
567: .append(" ");
568: buffer.append(COL_PRICE).append(" = ").append(price)
569: .append(" ");
570: buffer.append(COL_COST).append(" = ").append(cost).append(
571: " ");
572: buffer.append(COL_LAST_UPDATED).append(" = ").append(
573: lastUpdated).append(" ");
574: buffer.append(COL_CREATION_DATE).append(" = ").append(
575: creationDate).append(" ");
576: }
577: buffer.append("}}");
578: return buffer.toString();
579: }
580:
581: // naturalKey has no context
582:
583: /**
584: * Equals by Basic Peristent object fields (without children objects)
585: */
586: public boolean equalsBasic(Object value) {
587: if (this == value)
588: return true;
589: if (value == null || getClass() != value.getClass())
590: return false;
591:
592: ProductPO that = (ProductPO) value;
593:
594: if (productId != null ? !productId.equals(that.productId)
595: : that.productId != null)
596: return false;
597: if (name != null ? !name.equals(that.name) : that.name != null)
598: return false;
599: if (make != null ? !make.equals(that.make) : that.make != null)
600: return false;
601: if (model != null ? !model.equals(that.model)
602: : that.model != null)
603: return false;
604: if (colour != null ? !colour.equals(that.colour)
605: : that.colour != null)
606: return false;
607: if (price != null ? !price.equals(that.price)
608: : that.price != null)
609: return false;
610: if (cost != null ? !cost.equals(that.cost) : that.cost != null)
611: return false;
612: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
613: : that.lastUpdated != null)
614: return false;
615: if (creationDate != null ? !creationDate
616: .equals(that.creationDate) : that.creationDate != null)
617: return false;
618: return true;
619: }
620:
621: /**
622: * hashCode by Basic Peristent object fields (without children objects)
623: */
624: public int hashCodeBasic() {
625: int result;
626: long temp;
627: result = (productId != null ? productId.hashCode() : 0);
628: result = 29 * result + (name != null ? name.hashCode() : 0);
629: result = 29 * result + (make != null ? make.hashCode() : 0);
630: result = 29 * result + (model != null ? model.hashCode() : 0);
631: result = 29 * result + (colour != null ? colour.hashCode() : 0);
632: result = 29 * result + (price != null ? price.hashCode() : 0);
633: result = 29 * result + (cost != null ? cost.hashCode() : 0);
634: result = 29 * result
635: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
636: result = 29 * result
637: + (creationDate != null ? creationDate.hashCode() : 0);
638:
639: return result;
640: }
641: }
|