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