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