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.ForeignKeyEntry;
007: import com.completex.objective.components.persistency.MetaColumn;
008: import com.completex.objective.components.persistency.MetaTable;
009: import com.completex.objective.components.persistency.PersistentObject;
010: import com.completex.objective.components.persistency.Record;
011:
012: import java.util.Date;
013: import java.util.HashMap;
014: import java.util.Map;
015:
016: public class CustomerPO extends PersistentObject implements
017: java.io.Externalizable {
018: //
019: // Complex object related:
020: //
021:
022: //
023: private static Map registeredMasters;
024: private static Object lock = new Object();
025:
026: protected Object classLock() {
027: return lock;
028: }
029:
030: protected void instantiateRegisteredMasters() {
031: if (registeredMasters == null) {
032: synchronized (lock) {
033: if (registeredMasters == null) {
034: registeredMasters = new HashMap();
035: }
036: }
037: }
038: }
039:
040: protected Map registeredMasters() {
041: return registeredMasters;
042: }
043:
044: //
045: //
046: //
047:
048: public static final String TABLE_CUSTOMER = "CUSTOMER";
049:
050: public CustomerPO() {
051: super (new Record(table));
052: }
053:
054: public CustomerPO(Long customerId) {
055: this ();
056: setCustomerId(customerId);
057: }
058:
059: public static final String COL_CUSTOMER_ID = "CUSTOMER_ID";
060: public static final String TCOL_CUSTOMER_ID = "CUSTOMER.CUSTOMER_ID";
061: public static final int ICOL_CUSTOMER_ID = 0;
062: public static final int JDBC_TYPE_CUSTOMER_ID = -5;
063:
064: public static final String COL_CONTACT_ID = "CONTACT_ID";
065: public static final String TCOL_CONTACT_ID = "CUSTOMER.CONTACT_ID";
066: public static final int ICOL_CONTACT_ID = 1;
067: public static final int JDBC_TYPE_CONTACT_ID = -5;
068:
069: public static final String COL_ORG_NAME = "ORG_NAME";
070: public static final String TCOL_ORG_NAME = "CUSTOMER.ORG_NAME";
071: public static final int ICOL_ORG_NAME = 2;
072: public static final int JDBC_TYPE_ORG_NAME = 12;
073:
074: public static final String COL_URL = "URL";
075: public static final String TCOL_URL = "CUSTOMER.URL";
076: public static final int ICOL_URL = 3;
077: public static final int JDBC_TYPE_URL = 12;
078:
079: public static final String COL_LAST_UPDATED = "LAST_UPDATED";
080: public static final String TCOL_LAST_UPDATED = "CUSTOMER.LAST_UPDATED";
081: public static final int ICOL_LAST_UPDATED = 4;
082: public static final int JDBC_TYPE_LAST_UPDATED = 91;
083:
084: public static final String COL_CREATION_DATE = "CREATION_DATE";
085: public static final String TCOL_CREATION_DATE = "CUSTOMER.CREATION_DATE";
086: public static final int ICOL_CREATION_DATE = 5;
087: public static final int JDBC_TYPE_CREATION_DATE = 91;
088:
089: private static final MetaTable table = new MetaTable("CUSTOMER",
090: "CUSTOMER", 6, 1);
091:
092: static {
093: //
094: // Meta Foreign Keys:
095: //
096: table.addToForeignKey("CONTACT", new ForeignKeyEntry(
097: "CONTACT_ID", "CONTACT_ID"));
098: //
099: // Meta Natural Key:
100: //
101: // naturalKey has no context
102:
103: //
104: // Meta Columns:
105: //
106:
107: final MetaColumn metaCustomerId = new MetaColumn(
108: ICOL_CUSTOMER_ID, "CUSTOMER_ID", "CUSTOMER_ID", table);
109: metaCustomerId.setPrimaryKey(true);
110: metaCustomerId.setRequired(true);
111: metaCustomerId.setOptimisticLock(false);
112: metaCustomerId.setType(ColumnType.LONG);
113: metaCustomerId.setColumnSize(0);
114: metaCustomerId.setRemarks("");
115: metaCustomerId.setDecimalDigits(0);
116: metaCustomerId.setAutoGenerated(true);
117: metaCustomerId.setAutoIncrement(false);
118: metaCustomerId.setJdbcType(-5);
119: metaCustomerId
120: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
121: {
122: HashMap staticAttributes = new HashMap();
123: staticAttributes.put("name", "CUSTOMER_SEQ");
124: metaCustomerId
125: .setGeneratorStaticAttributes(staticAttributes);
126: }
127: metaCustomerId.initializeKeyGenerator();
128: table.addToPrimaryKey(new Integer(ICOL_CUSTOMER_ID));
129: table.addColumn(metaCustomerId);
130:
131: final MetaColumn metaContactId = new MetaColumn(
132: ICOL_CONTACT_ID, "CONTACT_ID", "CONTACT_ID", table);
133: metaContactId.setPrimaryKey(false);
134: metaContactId.setRequired(true);
135: metaContactId.setOptimisticLock(false);
136: metaContactId.setType(ColumnType.LONG);
137: metaContactId.setColumnSize(0);
138: metaContactId.setRemarks("");
139: metaContactId.setDecimalDigits(0);
140: metaContactId.setAutoGenerated(false);
141: metaContactId.setAutoIncrement(false);
142: metaContactId.setJdbcType(-5);
143: table.addColumn(metaContactId);
144:
145: final MetaColumn metaOrgName = new MetaColumn(ICOL_ORG_NAME,
146: "ORG_NAME", "ORG_NAME", table);
147: metaOrgName.setPrimaryKey(false);
148: metaOrgName.setRequired(true);
149: metaOrgName.setOptimisticLock(false);
150: metaOrgName.setType(ColumnType.STRING);
151: metaOrgName.setColumnSize(40);
152: metaOrgName.setRemarks("");
153: metaOrgName.setDecimalDigits(0);
154: metaOrgName.setAutoGenerated(false);
155: metaOrgName.setAutoIncrement(false);
156: metaOrgName.setJdbcType(12);
157: table.addColumn(metaOrgName);
158:
159: final MetaColumn metaUrl = new MetaColumn(ICOL_URL, "URL",
160: "URL", table);
161: metaUrl.setPrimaryKey(false);
162: metaUrl.setRequired(true);
163: metaUrl.setOptimisticLock(false);
164: metaUrl.setType(ColumnType.STRING);
165: metaUrl.setColumnSize(40);
166: metaUrl.setRemarks("");
167: metaUrl.setDecimalDigits(0);
168: metaUrl.setAutoGenerated(false);
169: metaUrl.setAutoIncrement(false);
170: metaUrl.setJdbcType(12);
171: table.addColumn(metaUrl);
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 metaCreationDate = new MetaColumn(
192: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
193: table);
194: metaCreationDate.setPrimaryKey(false);
195: metaCreationDate.setRequired(false);
196: metaCreationDate.setOptimisticLock(false);
197: metaCreationDate.setType(ColumnType.DATE);
198: metaCreationDate.setColumnSize(0);
199: metaCreationDate.setRemarks("");
200: metaCreationDate.setDecimalDigits(0);
201: metaCreationDate.setAutoGenerated(true);
202: metaCreationDate.setAutoIncrement(false);
203: metaCreationDate.setJdbcType(91);
204: metaCreationDate
205: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
206: metaCreationDate.initializeKeyGenerator();
207: table.addColumn(metaCreationDate);
208:
209: }
210:
211: private Long customerId;
212: private Long contactId;
213: private String orgName;
214: private String url;
215: private Date lastUpdated;
216: private Date creationDate;
217:
218: //
219: // customerId:
220: //
221: public Long getCustomerId() {
222: return this .customerId;
223: }
224:
225: public void setCustomerId(Long customerId) {
226: if (record2().setObject(ICOL_CUSTOMER_ID, customerId)) {
227: this .customerId = customerId;
228: }
229: }
230:
231: public boolean izNullCustomerId() {
232: return record2().getObject(ICOL_CUSTOMER_ID) == null;
233: }
234:
235: public void setNullCustomerId() {
236: if (record2().setObject(ICOL_CUSTOMER_ID, null)) {
237: this .customerId = null;
238: }
239: }
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: // orgName:
266: //
267: public String getOrgName() {
268: return this .orgName;
269: }
270:
271: public void setOrgName(String orgName) {
272: if (record2().setObject(ICOL_ORG_NAME, orgName)) {
273: this .orgName = orgName;
274: }
275: }
276:
277: public boolean izNullOrgName() {
278: return record2().getObject(ICOL_ORG_NAME) == null;
279: }
280:
281: public void setNullOrgName() {
282: if (record2().setObject(ICOL_ORG_NAME, null)) {
283: this .orgName = null;
284: }
285: }
286:
287: //
288: // url:
289: //
290: public String getUrl() {
291: return this .url;
292: }
293:
294: public void setUrl(String url) {
295: if (record2().setObject(ICOL_URL, url)) {
296: this .url = url;
297: }
298: }
299:
300: public boolean izNullUrl() {
301: return record2().getObject(ICOL_URL) == null;
302: }
303:
304: public void setNullUrl() {
305: if (record2().setObject(ICOL_URL, null)) {
306: this .url = 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: // creationDate:
335: //
336: public Date getCreationDate() {
337: return this .creationDate;
338: }
339:
340: public void setCreationDate(Date creationDate) {
341: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
342: this .creationDate = creationDate;
343: }
344: }
345:
346: public boolean izNullCreationDate() {
347: return record2().getObject(ICOL_CREATION_DATE) == null;
348: }
349:
350: public void setNullCreationDate() {
351: if (record2().setObject(ICOL_CREATION_DATE, null)) {
352: this .creationDate = null;
353: }
354: }
355:
356: public void toBeanFields() {
357: toBeanFields(this );
358: }
359:
360: public void toBeanFields(PersistentObject from) {
361: customerId = (Long) from.record2().getObject(ICOL_CUSTOMER_ID);
362: contactId = (Long) from.record2().getObject(ICOL_CONTACT_ID);
363: orgName = (String) from.record2().getObject(ICOL_ORG_NAME);
364: url = (String) from.record2().getObject(ICOL_URL);
365: lastUpdated = (Date) from.record2()
366: .getObject(ICOL_LAST_UPDATED);
367: creationDate = (Date) from.record2().getObject(
368: ICOL_CREATION_DATE);
369: super .toBeanFields(from);
370: }
371:
372: public void fromBeanFields(PersistentObject persistentObject) {
373: CustomerPO from = (CustomerPO) persistentObject;
374: record2().getEntry(ICOL_CUSTOMER_ID).setUnmarkedValue(
375: from.customerId, from.customerId);
376: record2().getEntry(ICOL_CONTACT_ID).setUnmarkedValue(
377: from.contactId, from.contactId);
378: record2().getEntry(ICOL_ORG_NAME).setUnmarkedValue(
379: from.orgName, from.orgName);
380: record2().getEntry(ICOL_URL).setUnmarkedValue(from.url,
381: from.url);
382: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
383: from.lastUpdated, from.lastUpdated);
384: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
385: from.creationDate, from.creationDate);
386: super .fromBeanFieldsDataSaved(persistentObject);
387: }
388:
389: public String toString() {
390:
391: StringBuffer buffer = new StringBuffer();
392: buffer.append("{ " + "class = ").append(
393: this .getClass().getName()).append(" " + "table = ")
394: .append(TABLE_CUSTOMER).append(" columns = {");
395:
396: if (record() != null) {
397: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
398: record().getObject(ICOL_CUSTOMER_ID)).append(" ");
399: buffer.append(COL_CONTACT_ID).append(" = ").append(
400: record().getObject(ICOL_CONTACT_ID)).append(" ");
401: buffer.append(COL_ORG_NAME).append(" = ").append(
402: record().getObject(ICOL_ORG_NAME)).append(" ");
403: buffer.append(COL_URL).append(" = ").append(
404: record().getObject(ICOL_URL)).append(" ");
405: buffer.append(COL_LAST_UPDATED).append(" = ").append(
406: record().getObject(ICOL_LAST_UPDATED)).append(" ");
407: buffer.append(COL_CREATION_DATE).append(" = ").append(
408: record().getObject(ICOL_CREATION_DATE)).append(" ");
409: } else {
410: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
411: customerId).append(" ");
412: buffer.append(COL_CONTACT_ID).append(" = ").append(
413: contactId).append(" ");
414: buffer.append(COL_ORG_NAME).append(" = ").append(orgName)
415: .append(" ");
416: buffer.append(COL_URL).append(" = ").append(url)
417: .append(" ");
418: buffer.append(COL_LAST_UPDATED).append(" = ").append(
419: lastUpdated).append(" ");
420: buffer.append(COL_CREATION_DATE).append(" = ").append(
421: creationDate).append(" ");
422: }
423: buffer.append("}}");
424: return buffer.toString();
425: }
426:
427: // naturalKey has no context
428:
429: /**
430: * Equals by Basic Peristent object fields (without children objects)
431: */
432: public boolean equalsBasic(Object value) {
433: if (this == value)
434: return true;
435: if (value == null || getClass() != value.getClass())
436: return false;
437:
438: CustomerPO that = (CustomerPO) value;
439:
440: if (customerId != null ? !customerId.equals(that.customerId)
441: : that.customerId != null)
442: return false;
443: if (contactId != null ? !contactId.equals(that.contactId)
444: : that.contactId != null)
445: return false;
446: if (orgName != null ? !orgName.equals(that.orgName)
447: : that.orgName != null)
448: return false;
449: if (url != null ? !url.equals(that.url) : that.url != null)
450: return false;
451: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
452: : that.lastUpdated != null)
453: return false;
454: if (creationDate != null ? !creationDate
455: .equals(that.creationDate) : that.creationDate != null)
456: return false;
457: return true;
458: }
459:
460: /**
461: * hashCode by Basic Peristent object fields (without children objects)
462: */
463: public int hashCodeBasic() {
464: int result;
465: long temp;
466: result = (customerId != null ? customerId.hashCode() : 0);
467: result = 29 * result
468: + (contactId != null ? contactId.hashCode() : 0);
469: result = 29 * result
470: + (orgName != null ? orgName.hashCode() : 0);
471: result = 29 * result + (url != null ? url.hashCode() : 0);
472: result = 29 * result
473: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
474: result = 29 * result
475: + (creationDate != null ? creationDate.hashCode() : 0);
476:
477: return result;
478: }
479: }
|