001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.completex.objective.persistency.examples.ex004.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: private static final MetaTable table = new MetaTable("CONTACT",
098: "CONTACT", 7, 1);
099:
100: static {
101: table.setStaticFinal(true);
102: //
103: // Meta Foreign Keys:
104: //
105: //
106: // Meta Natural Key:
107: //
108: // naturalKey has no context
109:
110: //
111: // Meta Columns:
112: //
113:
114: final MetaColumn metaContactId = new MetaColumn(
115: ICOL_CONTACT_ID, "CONTACT_ID", "CONTACT_ID", table);
116: metaContactId.setPrimaryKey(true);
117: metaContactId.setRequired(true);
118: metaContactId.setOptimisticLock(false);
119: metaContactId.setType(ColumnType.LONG);
120: metaContactId.setColumnSize(0);
121: metaContactId.setRemarks("");
122: metaContactId.setDecimalDigits(0);
123: metaContactId.setAutoGenerated(true);
124: metaContactId.setAutoIncrement(false);
125: metaContactId.setJdbcType(-5);
126: metaContactId
127: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
128: {
129: HashMap staticAttributes = new HashMap();
130: staticAttributes.put("name", "CONTACT_SEQ");
131: metaContactId
132: .setGeneratorStaticAttributes(staticAttributes);
133: }
134: metaContactId.initializeKeyGenerator();
135: table.addToPrimaryKey(new Integer(ICOL_CONTACT_ID));
136: table.addColumn(metaContactId);
137:
138: final MetaColumn metaFirstName = new MetaColumn(
139: ICOL_FIRST_NAME, "FIRST_NAME", "FIRST_NAME", table);
140: metaFirstName.setPrimaryKey(false);
141: metaFirstName.setRequired(true);
142: metaFirstName.setOptimisticLock(false);
143: metaFirstName.setType(ColumnType.STRING);
144: metaFirstName.setColumnSize(40);
145: metaFirstName.setRemarks("");
146: metaFirstName.setDecimalDigits(0);
147: metaFirstName.setAutoGenerated(false);
148: metaFirstName.setAutoIncrement(false);
149: metaFirstName.setJdbcType(12);
150: table.addColumn(metaFirstName);
151:
152: final MetaColumn metaLastName = new MetaColumn(ICOL_LAST_NAME,
153: "LAST_NAME", "LAST_NAME", table);
154: metaLastName.setPrimaryKey(false);
155: metaLastName.setRequired(true);
156: metaLastName.setOptimisticLock(false);
157: metaLastName.setType(ColumnType.STRING);
158: metaLastName.setColumnSize(40);
159: metaLastName.setRemarks("");
160: metaLastName.setDecimalDigits(0);
161: metaLastName.setAutoGenerated(false);
162: metaLastName.setAutoIncrement(false);
163: metaLastName.setJdbcType(12);
164: table.addColumn(metaLastName);
165:
166: final MetaColumn metaLastUpdated = new MetaColumn(
167: ICOL_LAST_UPDATED, "LAST_UPDATED", "LAST_UPDATED",
168: table);
169: metaLastUpdated.setPrimaryKey(false);
170: metaLastUpdated.setRequired(false);
171: metaLastUpdated.setOptimisticLock(false);
172: metaLastUpdated.setType(ColumnType.DATE);
173: metaLastUpdated.setColumnSize(0);
174: metaLastUpdated.setRemarks("");
175: metaLastUpdated.setDecimalDigits(0);
176: metaLastUpdated.setAutoGenerated(true);
177: metaLastUpdated.setAutoIncrement(false);
178: metaLastUpdated.setJdbcType(91);
179: metaLastUpdated
180: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
181: metaLastUpdated.initializeKeyGenerator();
182: table.addColumn(metaLastUpdated);
183:
184: final MetaColumn metaPhone = new MetaColumn(ICOL_PHONE,
185: "PHONE", "PHONE", table);
186: metaPhone.setPrimaryKey(false);
187: metaPhone.setRequired(true);
188: metaPhone.setOptimisticLock(false);
189: metaPhone.setType(ColumnType.STRING);
190: metaPhone.setColumnSize(40);
191: metaPhone.setRemarks("");
192: metaPhone.setDecimalDigits(0);
193: metaPhone.setAutoGenerated(false);
194: metaPhone.setAutoIncrement(false);
195: metaPhone.setJdbcType(12);
196: table.addColumn(metaPhone);
197:
198: final MetaColumn metaShipAddress = new MetaColumn(
199: ICOL_SHIP_ADDRESS, "SHIP_ADDRESS", "SHIP_ADDRESS",
200: table);
201: metaShipAddress.setPrimaryKey(false);
202: metaShipAddress.setRequired(true);
203: metaShipAddress.setOptimisticLock(false);
204: metaShipAddress.setType(ColumnType.STRING);
205: metaShipAddress.setColumnSize(255);
206: metaShipAddress.setRemarks("");
207: metaShipAddress.setDecimalDigits(0);
208: metaShipAddress.setAutoGenerated(false);
209: metaShipAddress.setAutoIncrement(false);
210: metaShipAddress.setJdbcType(12);
211: table.addColumn(metaShipAddress);
212:
213: final MetaColumn metaCreationDate = new MetaColumn(
214: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
215: table);
216: metaCreationDate.setPrimaryKey(false);
217: metaCreationDate.setRequired(false);
218: metaCreationDate.setOptimisticLock(false);
219: metaCreationDate.setType(ColumnType.DATE);
220: metaCreationDate.setColumnSize(0);
221: metaCreationDate.setRemarks("");
222: metaCreationDate.setDecimalDigits(0);
223: metaCreationDate.setAutoGenerated(true);
224: metaCreationDate.setAutoIncrement(false);
225: metaCreationDate.setJdbcType(91);
226: metaCreationDate
227: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
228: metaCreationDate.initializeKeyGenerator();
229: table.addColumn(metaCreationDate);
230:
231: }
232:
233: private Long contactId;
234: private String firstName;
235: private String lastName;
236: private Date lastUpdated;
237: private String phone;
238: private String shipAddress;
239: private Date creationDate;
240:
241: //
242: // contactId:
243: //
244: public Long getContactId() {
245: return this .contactId;
246: }
247:
248: public void setContactId(Long contactId) {
249: if (record2().setObject(ICOL_CONTACT_ID, contactId)) {
250: this .contactId = contactId;
251: }
252: }
253:
254: public boolean izNullContactId() {
255: return record2().getObject(ICOL_CONTACT_ID) == null;
256: }
257:
258: public void setNullContactId() {
259: if (record2().setObject(ICOL_CONTACT_ID, null)) {
260: this .contactId = null;
261: }
262: }
263:
264: //
265: // firstName:
266: //
267: public String getFirstName() {
268: return this .firstName;
269: }
270:
271: public void setFirstName(String firstName) {
272: if (record2().setObject(ICOL_FIRST_NAME, firstName)) {
273: this .firstName = firstName;
274: }
275: }
276:
277: public boolean izNullFirstName() {
278: return record2().getObject(ICOL_FIRST_NAME) == null;
279: }
280:
281: public void setNullFirstName() {
282: if (record2().setObject(ICOL_FIRST_NAME, null)) {
283: this .firstName = null;
284: }
285: }
286:
287: //
288: // lastName:
289: //
290: public String getLastName() {
291: return this .lastName;
292: }
293:
294: public void setLastName(String lastName) {
295: if (record2().setObject(ICOL_LAST_NAME, lastName)) {
296: this .lastName = lastName;
297: }
298: }
299:
300: public boolean izNullLastName() {
301: return record2().getObject(ICOL_LAST_NAME) == null;
302: }
303:
304: public void setNullLastName() {
305: if (record2().setObject(ICOL_LAST_NAME, null)) {
306: this .lastName = null;
307: }
308: }
309:
310: //
311: // lastUpdated:
312: //
313: public Date getLastUpdated() {
314: return this .lastUpdated;
315: }
316:
317: public void setLastUpdated(Date lastUpdated) {
318: if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
319: this .lastUpdated = lastUpdated;
320: }
321: }
322:
323: public boolean izNullLastUpdated() {
324: return record2().getObject(ICOL_LAST_UPDATED) == null;
325: }
326:
327: public void setNullLastUpdated() {
328: if (record2().setObject(ICOL_LAST_UPDATED, null)) {
329: this .lastUpdated = null;
330: }
331: }
332:
333: //
334: // phone:
335: //
336: public String getPhone() {
337: return this .phone;
338: }
339:
340: public void setPhone(String phone) {
341: if (record2().setObject(ICOL_PHONE, phone)) {
342: this .phone = phone;
343: }
344: }
345:
346: public boolean izNullPhone() {
347: return record2().getObject(ICOL_PHONE) == null;
348: }
349:
350: public void setNullPhone() {
351: if (record2().setObject(ICOL_PHONE, null)) {
352: this .phone = null;
353: }
354: }
355:
356: //
357: // shipAddress:
358: //
359: public String getShipAddress() {
360: return this .shipAddress;
361: }
362:
363: public void setShipAddress(String shipAddress) {
364: if (record2().setObject(ICOL_SHIP_ADDRESS, shipAddress)) {
365: this .shipAddress = shipAddress;
366: }
367: }
368:
369: public boolean izNullShipAddress() {
370: return record2().getObject(ICOL_SHIP_ADDRESS) == null;
371: }
372:
373: public void setNullShipAddress() {
374: if (record2().setObject(ICOL_SHIP_ADDRESS, null)) {
375: this .shipAddress = null;
376: }
377: }
378:
379: //
380: // creationDate:
381: //
382: public Date getCreationDate() {
383: return this .creationDate;
384: }
385:
386: public void setCreationDate(Date creationDate) {
387: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
388: this .creationDate = creationDate;
389: }
390: }
391:
392: public boolean izNullCreationDate() {
393: return record2().getObject(ICOL_CREATION_DATE) == null;
394: }
395:
396: public void setNullCreationDate() {
397: if (record2().setObject(ICOL_CREATION_DATE, null)) {
398: this .creationDate = null;
399: }
400: }
401:
402: public void toBeanFields() {
403: toBeanFields(this );
404: }
405:
406: public void toBeanFields(PersistentObject from) {
407: contactId = (Long) from.record2().getObject(ICOL_CONTACT_ID);
408: firstName = (String) from.record2().getObject(ICOL_FIRST_NAME);
409: lastName = (String) from.record2().getObject(ICOL_LAST_NAME);
410: lastUpdated = (Date) from.record2()
411: .getObject(ICOL_LAST_UPDATED);
412: phone = (String) from.record2().getObject(ICOL_PHONE);
413: shipAddress = (String) from.record2().getObject(
414: ICOL_SHIP_ADDRESS);
415: creationDate = (Date) from.record2().getObject(
416: ICOL_CREATION_DATE);
417: super .toBeanFields(from);
418: }
419:
420: public void fromBeanFields(PersistentObject persistentObject) {
421: ContactPO from = (ContactPO) persistentObject;
422: record2().getEntry(ICOL_CONTACT_ID).setUnmarkedValue(
423: from.contactId, from.contactId);
424: record2().getEntry(ICOL_FIRST_NAME).setUnmarkedValue(
425: from.firstName, from.firstName);
426: record2().getEntry(ICOL_LAST_NAME).setUnmarkedValue(
427: from.lastName, from.lastName);
428: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
429: from.lastUpdated, from.lastUpdated);
430: record2().getEntry(ICOL_PHONE).setUnmarkedValue(from.phone,
431: from.phone);
432: record2().getEntry(ICOL_SHIP_ADDRESS).setUnmarkedValue(
433: from.shipAddress, from.shipAddress);
434: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
435: from.creationDate, from.creationDate);
436: super .fromBeanFieldsDataSaved(persistentObject);
437: }
438:
439: public String toString() {
440:
441: StringBuffer buffer = new StringBuffer();
442: buffer.append("{ " + "class = ").append(
443: this .getClass().getName()).append(" " + "table = ")
444: .append(TABLE_CONTACT).append(" columns = {");
445:
446: if (record() != null) {
447: buffer.append(COL_CONTACT_ID).append(" = ").append(
448: record().getObject(ICOL_CONTACT_ID)).append(" ");
449: buffer.append(COL_FIRST_NAME).append(" = ").append(
450: record().getObject(ICOL_FIRST_NAME)).append(" ");
451: buffer.append(COL_LAST_NAME).append(" = ").append(
452: record().getObject(ICOL_LAST_NAME)).append(" ");
453: buffer.append(COL_LAST_UPDATED).append(" = ").append(
454: record().getObject(ICOL_LAST_UPDATED)).append(" ");
455: buffer.append(COL_PHONE).append(" = ").append(
456: record().getObject(ICOL_PHONE)).append(" ");
457: buffer.append(COL_SHIP_ADDRESS).append(" = ").append(
458: record().getObject(ICOL_SHIP_ADDRESS)).append(" ");
459: buffer.append(COL_CREATION_DATE).append(" = ").append(
460: record().getObject(ICOL_CREATION_DATE)).append(" ");
461: } else {
462: buffer.append(COL_CONTACT_ID).append(" = ").append(
463: contactId).append(" ");
464: buffer.append(COL_FIRST_NAME).append(" = ").append(
465: firstName).append(" ");
466: buffer.append(COL_LAST_NAME).append(" = ").append(lastName)
467: .append(" ");
468: buffer.append(COL_LAST_UPDATED).append(" = ").append(
469: lastUpdated).append(" ");
470: buffer.append(COL_PHONE).append(" = ").append(phone)
471: .append(" ");
472: buffer.append(COL_SHIP_ADDRESS).append(" = ").append(
473: shipAddress).append(" ");
474: buffer.append(COL_CREATION_DATE).append(" = ").append(
475: creationDate).append(" ");
476: }
477: buffer.append("}}");
478: return buffer.toString();
479: }
480:
481: // naturalKey has no context
482:
483: /**
484: * Equals by Basic Peristent object fields (without children objects)
485: */
486: public boolean equalsBasic(Object value) {
487: if (this == value)
488: return true;
489: if (value == null || getClass() != value.getClass())
490: return false;
491:
492: ContactPO that = (ContactPO) value;
493:
494: if (contactId != null ? !contactId.equals(that.contactId)
495: : that.contactId != null)
496: return false;
497: if (firstName != null ? !firstName.equals(that.firstName)
498: : that.firstName != null)
499: return false;
500: if (lastName != null ? !lastName.equals(that.lastName)
501: : that.lastName != null)
502: return false;
503: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
504: : that.lastUpdated != null)
505: return false;
506: if (phone != null ? !phone.equals(that.phone)
507: : that.phone != null)
508: return false;
509: if (shipAddress != null ? !shipAddress.equals(that.shipAddress)
510: : that.shipAddress != null)
511: return false;
512: if (creationDate != null ? !creationDate
513: .equals(that.creationDate) : that.creationDate != null)
514: return false;
515: return true;
516: }
517:
518: /**
519: * hashCode by Basic Peristent object fields (without children objects)
520: */
521: public int hashCodeBasic() {
522: int result;
523: long temp;
524: result = (contactId != null ? contactId.hashCode() : 0);
525: result = 29 * result
526: + (firstName != null ? firstName.hashCode() : 0);
527: result = 29 * result
528: + (lastName != null ? lastName.hashCode() : 0);
529: result = 29 * result
530: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
531: result = 29 * result + (phone != null ? phone.hashCode() : 0);
532: result = 29 * result
533: + (shipAddress != null ? shipAddress.hashCode() : 0);
534: result = 29 * result
535: + (creationDate != null ? creationDate.hashCode() : 0);
536:
537: return result;
538: }
539: }
|