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.ICustomerOrder;
018: import java.util.Date;
019:
020: public class CustomerOrderPO extends PersistentObject implements
021: ICustomerOrder, 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_CUSTOMER_ORDER = "CUSTOMER_ORDER";
053:
054: public CustomerOrderPO() {
055: super (new Record(table));
056: }
057:
058: public CustomerOrderPO(Long orderId) {
059: this ();
060: setOrderId(orderId);
061: }
062:
063: public static final String COL_ORDER_ID = "ORDER_ID";
064: public static final String TCOL_ORDER_ID = "CUSTOMER_ORDER.ORDER_ID";
065: public static final int ICOL_ORDER_ID = 0;
066: public static final int JDBC_TYPE_ORDER_ID = -5;
067:
068: public static final String COL_CUSTOMER_ID = "CUSTOMER_ID";
069: public static final String TCOL_CUSTOMER_ID = "CUSTOMER_ORDER.CUSTOMER_ID";
070: public static final int ICOL_CUSTOMER_ID = 1;
071: public static final int JDBC_TYPE_CUSTOMER_ID = -5;
072:
073: public static final String COL_LAST_UPDATED = "LAST_UPDATED";
074: public static final String TCOL_LAST_UPDATED = "CUSTOMER_ORDER.LAST_UPDATED";
075: public static final int ICOL_LAST_UPDATED = 2;
076: public static final int JDBC_TYPE_LAST_UPDATED = 91;
077:
078: public static final String COL_CREATION_DATE = "CREATION_DATE";
079: public static final String TCOL_CREATION_DATE = "CUSTOMER_ORDER.CREATION_DATE";
080: public static final int ICOL_CREATION_DATE = 3;
081: public static final int JDBC_TYPE_CREATION_DATE = 91;
082:
083: private static final MetaTable table = new MetaTable(
084: "CUSTOMER_ORDER", "CUSTOMER_ORDER", 4, 1);
085:
086: static {
087: table.setStaticFinal(true);
088: //
089: // Meta Foreign Keys:
090: //
091: table.addToForeignKey("CUSTOMER", new ForeignKeyEntry(
092: "CUSTOMER_ID", "CUSTOMER_ID"));
093: //
094: // Meta Natural Key:
095: //
096: // naturalKey has no context
097:
098: //
099: // Meta Columns:
100: //
101:
102: final MetaColumn metaOrderId = new MetaColumn(ICOL_ORDER_ID,
103: "ORDER_ID", "ORDER_ID", table);
104: metaOrderId.setPrimaryKey(true);
105: metaOrderId.setRequired(true);
106: metaOrderId.setOptimisticLock(false);
107: metaOrderId.setType(ColumnType.LONG);
108: metaOrderId.setColumnSize(0);
109: metaOrderId.setRemarks("");
110: metaOrderId.setDecimalDigits(0);
111: metaOrderId.setAutoGenerated(true);
112: metaOrderId.setAutoIncrement(false);
113: metaOrderId.setJdbcType(-5);
114: metaOrderId
115: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
116: {
117: HashMap staticAttributes = new HashMap();
118: staticAttributes.put("name", "CUSTOMER_ORDER_SEQ");
119: metaOrderId.setGeneratorStaticAttributes(staticAttributes);
120: }
121: metaOrderId.initializeKeyGenerator();
122: table.addToPrimaryKey(new Integer(ICOL_ORDER_ID));
123: table.addColumn(metaOrderId);
124:
125: final MetaColumn metaCustomerId = new MetaColumn(
126: ICOL_CUSTOMER_ID, "CUSTOMER_ID", "CUSTOMER_ID", table);
127: metaCustomerId.setPrimaryKey(false);
128: metaCustomerId.setRequired(true);
129: metaCustomerId.setOptimisticLock(false);
130: metaCustomerId.setType(ColumnType.LONG);
131: metaCustomerId.setColumnSize(0);
132: metaCustomerId.setRemarks("");
133: metaCustomerId.setDecimalDigits(0);
134: metaCustomerId.setAutoGenerated(false);
135: metaCustomerId.setAutoIncrement(false);
136: metaCustomerId.setJdbcType(-5);
137: table.addColumn(metaCustomerId);
138:
139: final MetaColumn metaLastUpdated = new MetaColumn(
140: ICOL_LAST_UPDATED, "LAST_UPDATED", "LAST_UPDATED",
141: table);
142: metaLastUpdated.setPrimaryKey(false);
143: metaLastUpdated.setRequired(false);
144: metaLastUpdated.setOptimisticLock(false);
145: metaLastUpdated.setType(ColumnType.DATE);
146: metaLastUpdated.setColumnSize(0);
147: metaLastUpdated.setRemarks("");
148: metaLastUpdated.setDecimalDigits(0);
149: metaLastUpdated.setAutoGenerated(true);
150: metaLastUpdated.setAutoIncrement(false);
151: metaLastUpdated.setJdbcType(91);
152: metaLastUpdated
153: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
154: metaLastUpdated.initializeKeyGenerator();
155: table.addColumn(metaLastUpdated);
156:
157: final MetaColumn metaCreationDate = new MetaColumn(
158: ICOL_CREATION_DATE, "CREATION_DATE", "CREATION_DATE",
159: table);
160: metaCreationDate.setPrimaryKey(false);
161: metaCreationDate.setRequired(false);
162: metaCreationDate.setOptimisticLock(false);
163: metaCreationDate.setType(ColumnType.DATE);
164: metaCreationDate.setColumnSize(0);
165: metaCreationDate.setRemarks("");
166: metaCreationDate.setDecimalDigits(0);
167: metaCreationDate.setAutoGenerated(true);
168: metaCreationDate.setAutoIncrement(false);
169: metaCreationDate.setJdbcType(91);
170: metaCreationDate
171: .setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
172: metaCreationDate.initializeKeyGenerator();
173: table.addColumn(metaCreationDate);
174:
175: }
176:
177: private Long orderId;
178: private Long customerId;
179: private Date lastUpdated;
180: private Date creationDate;
181:
182: //
183: // orderId:
184: //
185: public Long getOrderId() {
186: return this .orderId;
187: }
188:
189: public void setOrderId(Long orderId) {
190: if (record2().setObject(ICOL_ORDER_ID, orderId)) {
191: this .orderId = orderId;
192: }
193: }
194:
195: public boolean izNullOrderId() {
196: return record2().getObject(ICOL_ORDER_ID) == null;
197: }
198:
199: public void setNullOrderId() {
200: if (record2().setObject(ICOL_ORDER_ID, null)) {
201: this .orderId = null;
202: }
203: }
204:
205: //
206: // customerId:
207: //
208: public Long getCustomerId() {
209: return this .customerId;
210: }
211:
212: public void setCustomerId(Long customerId) {
213: if (record2().setObject(ICOL_CUSTOMER_ID, customerId)) {
214: this .customerId = customerId;
215: }
216: }
217:
218: public boolean izNullCustomerId() {
219: return record2().getObject(ICOL_CUSTOMER_ID) == null;
220: }
221:
222: public void setNullCustomerId() {
223: if (record2().setObject(ICOL_CUSTOMER_ID, null)) {
224: this .customerId = null;
225: }
226: }
227:
228: //
229: // lastUpdated:
230: //
231: public Date getLastUpdated() {
232: return this .lastUpdated;
233: }
234:
235: public void setLastUpdated(Date lastUpdated) {
236: if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
237: this .lastUpdated = lastUpdated;
238: }
239: }
240:
241: public boolean izNullLastUpdated() {
242: return record2().getObject(ICOL_LAST_UPDATED) == null;
243: }
244:
245: public void setNullLastUpdated() {
246: if (record2().setObject(ICOL_LAST_UPDATED, null)) {
247: this .lastUpdated = null;
248: }
249: }
250:
251: //
252: // creationDate:
253: //
254: public Date getCreationDate() {
255: return this .creationDate;
256: }
257:
258: public void setCreationDate(Date creationDate) {
259: if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
260: this .creationDate = creationDate;
261: }
262: }
263:
264: public boolean izNullCreationDate() {
265: return record2().getObject(ICOL_CREATION_DATE) == null;
266: }
267:
268: public void setNullCreationDate() {
269: if (record2().setObject(ICOL_CREATION_DATE, null)) {
270: this .creationDate = null;
271: }
272: }
273:
274: public void toBeanFields() {
275: toBeanFields(this );
276: }
277:
278: public void toBeanFields(PersistentObject from) {
279: orderId = (Long) from.record2().getObject(ICOL_ORDER_ID);
280: customerId = (Long) from.record2().getObject(ICOL_CUSTOMER_ID);
281: lastUpdated = (Date) from.record2()
282: .getObject(ICOL_LAST_UPDATED);
283: creationDate = (Date) from.record2().getObject(
284: ICOL_CREATION_DATE);
285: super .toBeanFields(from);
286: }
287:
288: public void fromBeanFields(PersistentObject persistentObject) {
289: CustomerOrderPO from = (CustomerOrderPO) persistentObject;
290: record2().getEntry(ICOL_ORDER_ID).setUnmarkedValue(
291: from.orderId, from.orderId);
292: record2().getEntry(ICOL_CUSTOMER_ID).setUnmarkedValue(
293: from.customerId, from.customerId);
294: record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(
295: from.lastUpdated, from.lastUpdated);
296: record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(
297: from.creationDate, from.creationDate);
298: super .fromBeanFieldsDataSaved(persistentObject);
299: }
300:
301: public String toString() {
302:
303: StringBuffer buffer = new StringBuffer();
304: buffer.append("{ " + "class = ").append(
305: this .getClass().getName()).append(" " + "table = ")
306: .append(TABLE_CUSTOMER_ORDER).append(" columns = {");
307:
308: if (record() != null) {
309: buffer.append(COL_ORDER_ID).append(" = ").append(
310: record().getObject(ICOL_ORDER_ID)).append(" ");
311: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
312: record().getObject(ICOL_CUSTOMER_ID)).append(" ");
313: buffer.append(COL_LAST_UPDATED).append(" = ").append(
314: record().getObject(ICOL_LAST_UPDATED)).append(" ");
315: buffer.append(COL_CREATION_DATE).append(" = ").append(
316: record().getObject(ICOL_CREATION_DATE)).append(" ");
317: } else {
318: buffer.append(COL_ORDER_ID).append(" = ").append(orderId)
319: .append(" ");
320: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
321: customerId).append(" ");
322: buffer.append(COL_LAST_UPDATED).append(" = ").append(
323: lastUpdated).append(" ");
324: buffer.append(COL_CREATION_DATE).append(" = ").append(
325: creationDate).append(" ");
326: }
327: buffer.append("}}");
328: return buffer.toString();
329: }
330:
331: // naturalKey has no context
332:
333: /**
334: * Equals by Basic Peristent object fields (without children objects)
335: */
336: public boolean equalsBasic(Object value) {
337: if (this == value)
338: return true;
339: if (value == null || getClass() != value.getClass())
340: return false;
341:
342: CustomerOrderPO that = (CustomerOrderPO) value;
343:
344: if (orderId != null ? !orderId.equals(that.orderId)
345: : that.orderId != null)
346: return false;
347: if (customerId != null ? !customerId.equals(that.customerId)
348: : that.customerId != null)
349: return false;
350: if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated)
351: : that.lastUpdated != null)
352: return false;
353: if (creationDate != null ? !creationDate
354: .equals(that.creationDate) : that.creationDate != null)
355: return false;
356: return true;
357: }
358:
359: /**
360: * hashCode by Basic Peristent object fields (without children objects)
361: */
362: public int hashCodeBasic() {
363: int result;
364: long temp;
365: result = (orderId != null ? orderId.hashCode() : 0);
366: result = 29 * result
367: + (customerId != null ? customerId.hashCode() : 0);
368: result = 29 * result
369: + (lastUpdated != null ? lastUpdated.hashCode() : 0);
370: result = 29 * result
371: + (creationDate != null ? creationDate.hashCode() : 0);
372:
373: return result;
374: }
375: }
|