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.IContact;
018: import java.util.Date;
019:
020: public class ContactPO extends PersistentObject implements IContact,
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_CONTACT = "CONTACT";
053:
054: public ContactPO() {
055: super (new Record(table));
056: }
057:
058: public ContactPO(Long contactId) {
059: this ();
060: setContactId(contactId);
061: }
062:
063: public static final String COL_CONTACT_ID = "CONTACT_ID";
064: public static final String TCOL_CONTACT_ID = "CONTACT.CONTACT_ID";
065: public static final int ICOL_CONTACT_ID = 0;
066: public static final int JDBC_TYPE_CONTACT_ID = -5;
067:
068: public static final String COL_FIRST_NAME = "FIRST_NAME";
069: public static final String TCOL_FIRST_NAME = "CONTACT.FIRST_NAME";
070: public static final int ICOL_FIRST_NAME = 1;
071: public static final int JDBC_TYPE_FIRST_NAME = 12;
072:
073: public static final String COL_LAST_NAME = "LAST_NAME";
074: public static final String TCOL_LAST_NAME = "CONTACT.LAST_NAME";
075: public static final int ICOL_LAST_NAME = 2;
076: public static final int JDBC_TYPE_LAST_NAME = 12;
077:
078: public static final String COL_LAST_UPDATED = "LAST_UPDATED";
079: public static final String TCOL_LAST_UPDATED = "CONTACT.LAST_UPDATED";
080: public static final int ICOL_LAST_UPDATED = 3;
081: public static final int JDBC_TYPE_LAST_UPDATED = 91;
082:
083: public static final String COL_PHONE = "PHONE";
084: public static final String TCOL_PHONE = "CONTACT.PHONE";
085: public static final int ICOL_PHONE = 4;
086: public static final int JDBC_TYPE_PHONE = 12;
087:
088: public static final String COL_SHIP_ADDRESS = "SHIP_ADDRESS";
089: public static final String TCOL_SHIP_ADDRESS = "CONTACT.SHIP_ADDRESS";
090: public static final int ICOL_SHIP_ADDRESS = 5;
091: public static final int JDBC_TYPE_SHIP_ADDRESS = 12;
092:
093: public static final String COL_CREATION_DATE = "CREATION_DATE";
094: public static final String TCOL_CREATION_DATE = "CONTACT.CREATION_DATE";
095: public static final int ICOL_CREATION_DATE = 6;
096: public static final int JDBC_TYPE_CREATION_DATE = 91;
097:
098: public static final String COL_CUSTOMER_ID = "CUSTOMER_ID";
099: public static final String TCOL_CUSTOMER_ID = "CONTACT.CUSTOMER_ID";
100: public static final int ICOL_CUSTOMER_ID = 7;
101: public static final int JDBC_TYPE_CUSTOMER_ID = -5;
102:
103: private static final MetaTable table = new MetaTable("CONTACT",
104: "CONTACT", 8, 1);
105:
106: static {
107: table.setStaticFinal(true);
108: //
109: // Meta Foreign Keys:
110: //
111: table.addToForeignKey("CUSTOMER", new ForeignKeyEntry(
112: "CUSTOMER_ID", "CUSTOMER_ID"));
113: //
114: // Meta Natural Key:
115: //
116: // naturalKey has no context
117:
118: //
119: // Meta Columns:
120: //
121:
122: final MetaColumn metaContactId = new MetaColumn(
123: ICOL_CONTACT_ID, "CONTACT_ID", "CONTACT_ID", table);
124: metaContactId.setPrimaryKey(true);
125: metaContactId.setRequired(true);
126: metaContactId.setOptimisticLock(false);
127: metaContactId.setType(ColumnType.LONG);
128: metaContactId.setColumnSize(0);
129: metaContactId.setRemarks("");
130: metaContactId.setDecimalDigits(0);
131: metaContactId.setAutoGenerated(true);
132: metaContactId.setAutoIncrement(false);
133: metaContactId.setJdbcType(-5);
134: metaContactId
135: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
136: {
137: HashMap staticAttributes = new HashMap();
138: staticAttributes.put("name", "CONTACT_SEQ");
139: metaContactId
140: .setGeneratorStaticAttributes(staticAttributes);
141: }
142: metaContactId.initializeKeyGenerator();
143: table.addToPrimaryKey(new Integer(ICOL_CONTACT_ID));
144: table.addColumn(metaContactId);
145:
146: final MetaColumn metaFirstName = new MetaColumn(
147: ICOL_FIRST_NAME, "FIRST_NAME", "FIRST_NAME", table);
148: metaFirstName.setPrimaryKey(false);
149: metaFirstName.setRequired(true);
150: metaFirstName.setOptimisticLock(false);
151: metaFirstName.setType(ColumnType.STRING);
152: metaFirstName.setColumnSize(40);
153: metaFirstName.setRemarks("");
154: metaFirstName.setDecimalDigits(0);
155: metaFirstName.setAutoGenerated(false);
156: metaFirstName.setAutoIncrement(false);
157: metaFirstName.setJdbcType(12);
158: table.addColumn(metaFirstName);
159:
160: final MetaColumn metaLastName = new MetaColumn(ICOL_LAST_NAME,
161: "LAST_NAME", "LAST_NAME", table);
162: metaLastName.setPrimaryKey(false);
163: metaLastName.setRequired(true);
164: metaLastName.setOptimisticLock(false);
165: metaLastName.setType(ColumnType.STRING);
166: metaLastName.setColumnSize(40);
167: metaLastName.setRemarks("");
168: metaLastName.setDecimalDigits(0);
169: metaLastName.setAutoGenerated(false);
170: metaLastName.setAutoIncrement(false);
171: metaLastName.setJdbcType(12);
172: table.addColumn(metaLastName);
173:
174: final MetaColumn metaLastUpdated = new MetaColumn(
175: ICOL_LAST_UPDATED, "LAST_UPDATED", "LAST_UPDATED",
176: table);
177: metaLastUpdated.setPrimaryKey(false);
178: metaLastUpdated.setRequired(false);
179: metaLastUpdated.setOptimisticLock(false);
180: metaLastUpdated.setType(ColumnType.DATE);
181: metaLastUpdated.setColumnSize(0);
182: metaLastUpdated.setRemarks("");
183: metaLastUpdated.setDecimalDigits(0);
184: metaLastUpdated.setAutoGenerated(true);
185: metaLastUpdated.setAutoIncrement(false);
186: metaLastUpdated.setJdbcType(91);
187: metaLastUpdated
188: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
189: metaLastUpdated.initializeKeyGenerator();
190: table.addColumn(metaLastUpdated);
191:
192: final MetaColumn metaPhone = new MetaColumn(ICOL_PHONE,
193: "PHONE", "PHONE", table);
194: metaPhone.setPrimaryKey(false);
195: metaPhone.setRequired(true);
196: metaPhone.setOptimisticLock(false);
197: metaPhone.setType(ColumnType.STRING);
198: metaPhone.setColumnSize(40);
199: metaPhone.setRemarks("");
200: metaPhone.setDecimalDigits(0);
201: metaPhone.setAutoGenerated(false);
202: metaPhone.setAutoIncrement(false);
203: metaPhone.setJdbcType(12);
204: table.addColumn(metaPhone);
205:
206: final MetaColumn metaShipAddress = new MetaColumn(
207: ICOL_SHIP_ADDRESS, "SHIP_ADDRESS", "SHIP_ADDRESS",
208: table);
209: metaShipAddress.setPrimaryKey(false);
210: metaShipAddress.setRequired(true);
211: metaShipAddress.setOptimisticLock(false);
212: metaShipAddress.setType(ColumnType.STRING);
213: metaShipAddress.setColumnSize(255);
214: metaShipAddress.setRemarks("");
215: metaShipAddress.setDecimalDigits(0);
216: metaShipAddress.setAutoGenerated(false);
217: metaShipAddress.setAutoIncrement(false);
218: metaShipAddress.setJdbcType(12);
219: table.addColumn(metaShipAddress);
220:
221: final MetaColumn metaCreationDate = new MetaColumn(
222: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
223: table);
224: metaCreationDate.setPrimaryKey(false);
225: metaCreationDate.setRequired(false);
226: metaCreationDate.setOptimisticLock(false);
227: metaCreationDate.setType(ColumnType.DATE);
228: metaCreationDate.setColumnSize(0);
229: metaCreationDate.setRemarks("");
230: metaCreationDate.setDecimalDigits(0);
231: metaCreationDate.setAutoGenerated(true);
232: metaCreationDate.setAutoIncrement(false);
233: metaCreationDate.setJdbcType(91);
234: metaCreationDate
235: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
236: metaCreationDate.initializeKeyGenerator();
237: table.addColumn(metaCreationDate);
238:
239: final MetaColumn metaCustomerId = new MetaColumn(
240: ICOL_CUSTOMER_ID, "CUSTOMER_ID", "CUSTOMER_ID", table);
241: metaCustomerId.setPrimaryKey(false);
242: metaCustomerId.setRequired(true);
243: metaCustomerId.setOptimisticLock(false);
244: metaCustomerId.setType(ColumnType.LONG);
245: metaCustomerId.setColumnSize(0);
246: metaCustomerId.setRemarks("");
247: metaCustomerId.setDecimalDigits(0);
248: metaCustomerId.setAutoGenerated(false);
249: metaCustomerId.setAutoIncrement(false);
250: metaCustomerId.setJdbcType(-5);
251: table.addColumn(metaCustomerId);
252:
253: }
254:
255: private Long contactId;
256: private String firstName;
257: private String lastName;
258: private Date lastUpdated;
259: private String phone;
260: private String shipAddress;
261: private Date creationDate;
262: private Long customerId;
263:
264: //
265: // contactId:
266: //
267: public Long getContactId() {
268: return this .contactId;
269: }
270:
271: public void setContactId(Long contactId) {
272: if (record2().setObject(ICOL_CONTACT_ID, contactId)) {
273: this .contactId = contactId;
274: }
275: }
276:
277: public boolean izNullContactId() {
278: return record2().getObject(ICOL_CONTACT_ID) == null;
279: }
280:
281: public void setNullContactId() {
282: if (record2().setObject(ICOL_CONTACT_ID, null)) {
283: this .contactId = null;
284: }
285: }
286:
287: //
288: // firstName:
289: //
290: public String getFirstName() {
291: return this .firstName;
292: }
293:
294: public void setFirstName(String firstName) {
295: if (record2().setObject(ICOL_FIRST_NAME, firstName)) {
296: this .firstName = firstName;
297: }
298: }
299:
300: public boolean izNullFirstName() {
301: return record2().getObject(ICOL_FIRST_NAME) == null;
302: }
303:
304: public void setNullFirstName() {
305: if (record2().setObject(ICOL_FIRST_NAME, null)) {
306: this .firstName = null;
307: }
308: }
309:
310: //
311: // lastName:
312: //
313: public String getLastName() {
314: return this .lastName;
315: }
316:
317: public void setLastName(String lastName) {
318: if (record2().setObject(ICOL_LAST_NAME, lastName)) {
319: this .lastName = lastName;
320: }
321: }
322:
323: public boolean izNullLastName() {
324: return record2().getObject(ICOL_LAST_NAME) == null;
325: }
326:
327: public void setNullLastName() {
328: if (record2().setObject(ICOL_LAST_NAME, null)) {
329: this .lastName = null;
330: }
331: }
332:
333: //
334: // lastUpdated:
335: //
336: public Date getLastUpdated() {
337: return this .lastUpdated;
338: }
339:
340: public void setLastUpdated(Date lastUpdated) {
341: if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
342: this .lastUpdated = lastUpdated;
343: }
344: }
345:
346: public boolean izNullLastUpdated() {
347: return record2().getObject(ICOL_LAST_UPDATED) == null;
348: }
349:
350: public void setNullLastUpdated() {
351: if (record2().setObject(ICOL_LAST_UPDATED, null)) {
352: this .lastUpdated = null;
353: }
354: }
355:
356: //
357: // phone:
358: //
359: public String getPhone() {
360: return this .phone;
361: }
362:
363: public void setPhone(String phone) {
364: if (record2().setObject(ICOL_PHONE, phone)) {
365: this .phone = phone;
366: }
367: }
368:
369: public boolean izNullPhone() {
370: return record2().getObject(ICOL_PHONE) == null;
371: }
372:
373: public void setNullPhone() {
374: if (record2().setObject(ICOL_PHONE, null)) {
375: this .phone = null;
376: }
377: }
378:
379: //
380: // shipAddress:
381: //
382: public String getShipAddress() {
383: return this .shipAddress;
384: }
385:
386: public void setShipAddress(String shipAddress) {
387: if (record2().setObject(ICOL_SHIP_ADDRESS, shipAddress)) {
388: this .shipAddress = shipAddress;
389: }
390: }
391:
392: public boolean izNullShipAddress() {
393: return record2().getObject(ICOL_SHIP_ADDRESS) == null;
394: }
395:
396: public void setNullShipAddress() {
397: if (record2().setObject(ICOL_SHIP_ADDRESS, null)) {
398: this .shipAddress = null;
399: }
400: }
401:
402: //
403: // creationDate:
404: //
405: public Date getCreationDate() {
406: return this .creationDate;
407: }
408:
409: public void setCreationDate(Date creationDate) {
410: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
411: this .creationDate = creationDate;
412: }
413: }
414:
415: public boolean izNullCreationDate() {
416: return record2().getObject(ICOL_CREATION_DATE) == null;
417: }
418:
419: public void setNullCreationDate() {
420: if (record2().setObject(ICOL_CREATION_DATE, null)) {
421: this .creationDate = null;
422: }
423: }
424:
425: //
426: // customerId:
427: //
428: public Long getCustomerId() {
429: return this .customerId;
430: }
431:
432: public void setCustomerId(Long customerId) {
433: if (record2().setObject(ICOL_CUSTOMER_ID, customerId)) {
434: this .customerId = customerId;
435: }
436: }
437:
438: public boolean izNullCustomerId() {
439: return record2().getObject(ICOL_CUSTOMER_ID) == null;
440: }
441:
442: public void setNullCustomerId() {
443: if (record2().setObject(ICOL_CUSTOMER_ID, null)) {
444: this .customerId = null;
445: }
446: }
447:
448: public void toBeanFields() {
449: toBeanFields(this );
450: }
451:
452: public void toBeanFields(PersistentObject from) {
453: contactId = (Long) from.record2().getObject(ICOL_CONTACT_ID);
454: firstName = (String) from.record2().getObject(ICOL_FIRST_NAME);
455: lastName = (String) from.record2().getObject(ICOL_LAST_NAME);
456: lastUpdated = (Date) from.record2()
457: .getObject(ICOL_LAST_UPDATED);
458: phone = (String) from.record2().getObject(ICOL_PHONE);
459: shipAddress = (String) from.record2().getObject(
460: ICOL_SHIP_ADDRESS);
461: creationDate = (Date) from.record2().getObject(
462: ICOL_CREATION_DATE);
463: customerId = (Long) from.record2().getObject(ICOL_CUSTOMER_ID);
464: super .toBeanFields(from);
465: }
466:
467: public void fromBeanFields(PersistentObject persistentObject) {
468: ContactPO from = (ContactPO) persistentObject;
469: record2().getEntry(ICOL_CONTACT_ID).setUnmarkedValue(
470: from.contactId, from.contactId);
471: record2().getEntry(ICOL_FIRST_NAME).setUnmarkedValue(
472: from.firstName, from.firstName);
473: record2().getEntry(ICOL_LAST_NAME).setUnmarkedValue(
474: from.lastName, from.lastName);
475: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
476: from.lastUpdated, from.lastUpdated);
477: record2().getEntry(ICOL_PHONE).setUnmarkedValue(from.phone,
478: from.phone);
479: record2().getEntry(ICOL_SHIP_ADDRESS).setUnmarkedValue(
480: from.shipAddress, from.shipAddress);
481: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
482: from.creationDate, from.creationDate);
483: record2().getEntry(ICOL_CUSTOMER_ID).setUnmarkedValue(
484: from.customerId, from.customerId);
485: super .fromBeanFieldsDataSaved(persistentObject);
486: }
487:
488: public String toString() {
489:
490: StringBuffer buffer = new StringBuffer();
491: buffer.append("{ " + "class = ").append(
492: this .getClass().getName()).append(" " + "table = ")
493: .append(TABLE_CONTACT).append(" columns = {");
494:
495: if (record() != null) {
496: buffer.append(COL_CONTACT_ID).append(" = ").append(
497: record().getObject(ICOL_CONTACT_ID)).append(" ");
498: buffer.append(COL_FIRST_NAME).append(" = ").append(
499: record().getObject(ICOL_FIRST_NAME)).append(" ");
500: buffer.append(COL_LAST_NAME).append(" = ").append(
501: record().getObject(ICOL_LAST_NAME)).append(" ");
502: buffer.append(COL_LAST_UPDATED).append(" = ").append(
503: record().getObject(ICOL_LAST_UPDATED)).append(" ");
504: buffer.append(COL_PHONE).append(" = ").append(
505: record().getObject(ICOL_PHONE)).append(" ");
506: buffer.append(COL_SHIP_ADDRESS).append(" = ").append(
507: record().getObject(ICOL_SHIP_ADDRESS)).append(" ");
508: buffer.append(COL_CREATION_DATE).append(" = ").append(
509: record().getObject(ICOL_CREATION_DATE)).append(" ");
510: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
511: record().getObject(ICOL_CUSTOMER_ID)).append(" ");
512: } else {
513: buffer.append(COL_CONTACT_ID).append(" = ").append(
514: contactId).append(" ");
515: buffer.append(COL_FIRST_NAME).append(" = ").append(
516: firstName).append(" ");
517: buffer.append(COL_LAST_NAME).append(" = ").append(lastName)
518: .append(" ");
519: buffer.append(COL_LAST_UPDATED).append(" = ").append(
520: lastUpdated).append(" ");
521: buffer.append(COL_PHONE).append(" = ").append(phone)
522: .append(" ");
523: buffer.append(COL_SHIP_ADDRESS).append(" = ").append(
524: shipAddress).append(" ");
525: buffer.append(COL_CREATION_DATE).append(" = ").append(
526: creationDate).append(" ");
527: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
528: customerId).append(" ");
529: }
530: buffer.append("}}");
531: return buffer.toString();
532: }
533:
534: // naturalKey has no context
535:
536: /**
537: * Equals by Basic Peristent object fields (without children objects)
538: */
539: public boolean equalsBasic(Object value) {
540: if (this == value)
541: return true;
542: if (value == null || getClass() != value.getClass())
543: return false;
544:
545: ContactPO that = (ContactPO) value;
546:
547: if (contactId != null ? !contactId.equals(that.contactId)
548: : that.contactId != null)
549: return false;
550: if (firstName != null ? !firstName.equals(that.firstName)
551: : that.firstName != null)
552: return false;
553: if (lastName != null ? !lastName.equals(that.lastName)
554: : that.lastName != null)
555: return false;
556: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
557: : that.lastUpdated != null)
558: return false;
559: if (phone != null ? !phone.equals(that.phone)
560: : that.phone != null)
561: return false;
562: if (shipAddress != null ? !shipAddress.equals(that.shipAddress)
563: : that.shipAddress != null)
564: return false;
565: if (creationDate != null ? !creationDate
566: .equals(that.creationDate) : that.creationDate != null)
567: return false;
568: if (customerId != null ? !customerId.equals(that.customerId)
569: : that.customerId != null)
570: return false;
571: return true;
572: }
573:
574: /**
575: * hashCode by Basic Peristent object fields (without children objects)
576: */
577: public int hashCodeBasic() {
578: int result;
579: long temp;
580: result = (contactId != null ? contactId.hashCode() : 0);
581: result = 29 * result
582: + (firstName != null ? firstName.hashCode() : 0);
583: result = 29 * result
584: + (lastName != null ? lastName.hashCode() : 0);
585: result = 29 * result
586: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
587: result = 29 * result + (phone != null ? phone.hashCode() : 0);
588: result = 29 * result
589: + (shipAddress != null ? shipAddress.hashCode() : 0);
590: result = 29 * result
591: + (creationDate != null ? creationDate.hashCode() : 0);
592: result = 29 * result
593: + (customerId != null ? customerId.hashCode() : 0);
594:
595: return result;
596: }
597: }
|