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