001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.odal.petstore.persistence.gen.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.math.BigDecimal;
018:
019: public class LineItemPO 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_LINE_ITEM = "LINE_ITEM";
052:
053: public LineItemPO() {
054: super (new Record(table));
055: }
056:
057: public LineItemPO(long lineNum, long orderId) {
058: this ();
059: setLineNum(lineNum);
060: setOrderId(orderId);
061: }
062:
063: public static final String COL_ORDER_ID = "ORDER_ID";
064: public static final String TCOL_ORDER_ID = "LINE_ITEM.ORDER_ID";
065: public static final int ICOL_ORDER_ID = 0;
066: public static final int JDBC_TYPE_ORDER_ID = 4;
067:
068: public static final String COL_LINE_NUM = "LINE_NUM";
069: public static final String TCOL_LINE_NUM = "LINE_ITEM.LINE_NUM";
070: public static final int ICOL_LINE_NUM = 1;
071: public static final int JDBC_TYPE_LINE_NUM = 4;
072:
073: public static final String COL_ITEM_ID = "ITEM_ID";
074: public static final String TCOL_ITEM_ID = "LINE_ITEM.ITEM_ID";
075: public static final int ICOL_ITEM_ID = 2;
076: public static final int JDBC_TYPE_ITEM_ID = 12;
077:
078: public static final String COL_QUANTITY = "QUANTITY";
079: public static final String TCOL_QUANTITY = "LINE_ITEM.QUANTITY";
080: public static final int ICOL_QUANTITY = 3;
081: public static final int JDBC_TYPE_QUANTITY = 4;
082:
083: public static final String COL_UNIT_PRICE = "UNIT_PRICE";
084: public static final String TCOL_UNIT_PRICE = "LINE_ITEM.UNIT_PRICE";
085: public static final int ICOL_UNIT_PRICE = 4;
086: public static final int JDBC_TYPE_UNIT_PRICE = 3;
087:
088: private static final MetaTable table = new MetaTable("LINE_ITEM",
089: "LINE_ITEM", 5, 2);
090:
091: static {
092: table.setStaticFinal(true);
093: //
094: // Meta Foreign Keys:
095: //
096: table.addToForeignKey("ORDERS", new ForeignKeyEntry("ORDER_ID",
097: "ORDER_ID"));
098: //
099: // Meta Natural Key:
100: //
101: // naturalKey has no context
102:
103: //
104: // Meta Columns:
105: //
106:
107: final MetaColumn metaOrderId = new MetaColumn(ICOL_ORDER_ID,
108: "ORDER_ID", "ORDER_ID", table);
109: metaOrderId.setPrimaryKey(true);
110: metaOrderId.setRequired(true);
111: metaOrderId.setOptimisticLock(false);
112: metaOrderId.setType(ColumnType.LONG_PRIMITIVE);
113: metaOrderId.setColumnSize(0);
114: metaOrderId.setRemarks("");
115: metaOrderId.setDecimalDigits(0);
116: metaOrderId.setAutoGenerated(false);
117: metaOrderId.setAutoIncrement(false);
118: metaOrderId.setJdbcType(4);
119: table.addToPrimaryKey(new Integer(ICOL_ORDER_ID));
120: table.addColumn(metaOrderId);
121:
122: final MetaColumn metaLineNum = new MetaColumn(ICOL_LINE_NUM,
123: "LINE_NUM", "LINE_NUM", table);
124: metaLineNum.setPrimaryKey(true);
125: metaLineNum.setRequired(true);
126: metaLineNum.setOptimisticLock(false);
127: metaLineNum.setType(ColumnType.LONG_PRIMITIVE);
128: metaLineNum.setColumnSize(0);
129: metaLineNum.setRemarks("");
130: metaLineNum.setDecimalDigits(0);
131: metaLineNum.setAutoGenerated(false);
132: metaLineNum.setAutoIncrement(false);
133: metaLineNum.setJdbcType(4);
134: table.addToPrimaryKey(new Integer(ICOL_LINE_NUM));
135: table.addColumn(metaLineNum);
136:
137: final MetaColumn metaItemId = new MetaColumn(ICOL_ITEM_ID,
138: "ITEM_ID", "ITEM_ID", table);
139: metaItemId.setPrimaryKey(false);
140: metaItemId.setRequired(true);
141: metaItemId.setOptimisticLock(false);
142: metaItemId.setType(ColumnType.STRING);
143: metaItemId.setColumnSize(10);
144: metaItemId.setRemarks("");
145: metaItemId.setDecimalDigits(0);
146: metaItemId.setAutoGenerated(false);
147: metaItemId.setAutoIncrement(false);
148: metaItemId.setJdbcType(12);
149: table.addColumn(metaItemId);
150:
151: final MetaColumn metaQuantity = new MetaColumn(ICOL_QUANTITY,
152: "QUANTITY", "QUANTITY", table);
153: metaQuantity.setPrimaryKey(false);
154: metaQuantity.setRequired(true);
155: metaQuantity.setOptimisticLock(false);
156: metaQuantity.setType(ColumnType.LONG_PRIMITIVE);
157: metaQuantity.setColumnSize(0);
158: metaQuantity.setRemarks("");
159: metaQuantity.setDecimalDigits(0);
160: metaQuantity.setAutoGenerated(false);
161: metaQuantity.setAutoIncrement(false);
162: metaQuantity.setJdbcType(4);
163: table.addColumn(metaQuantity);
164:
165: final MetaColumn metaUnitPrice = new MetaColumn(
166: ICOL_UNIT_PRICE, "UNIT_PRICE", "UNIT_PRICE", table);
167: metaUnitPrice.setPrimaryKey(false);
168: metaUnitPrice.setRequired(true);
169: metaUnitPrice.setOptimisticLock(false);
170: metaUnitPrice.setType(ColumnType.BIGDECIMAL);
171: metaUnitPrice.setColumnSize(10);
172: metaUnitPrice.setRemarks("");
173: metaUnitPrice.setDecimalDigits(2);
174: metaUnitPrice.setAutoGenerated(false);
175: metaUnitPrice.setAutoIncrement(false);
176: metaUnitPrice.setJdbcType(3);
177: table.addColumn(metaUnitPrice);
178:
179: }
180:
181: private long orderId;
182: private long lineNum;
183: private String itemId;
184: private long quantity;
185: private BigDecimal unitPrice;
186:
187: //
188: // orderId:
189: //
190: public long getOrderId() {
191: return this .orderId;
192: }
193:
194: public void setOrderId(long orderId) {
195: if (record2().setObject(ICOL_ORDER_ID, long2Number(orderId))) {
196: this .orderId = orderId;
197: }
198: }
199:
200: public boolean izNullOrderId() {
201: return record2().getObject(ICOL_ORDER_ID) == null;
202: }
203:
204: public void setNullOrderId() {
205: if (record2().setObject(ICOL_ORDER_ID, null)) {
206: this .orderId = Number2long(null);
207: }
208: }
209:
210: //
211: // lineNum:
212: //
213: public long getLineNum() {
214: return this .lineNum;
215: }
216:
217: public void setLineNum(long lineNum) {
218: if (record2().setObject(ICOL_LINE_NUM, long2Number(lineNum))) {
219: this .lineNum = lineNum;
220: }
221: }
222:
223: public boolean izNullLineNum() {
224: return record2().getObject(ICOL_LINE_NUM) == null;
225: }
226:
227: public void setNullLineNum() {
228: if (record2().setObject(ICOL_LINE_NUM, null)) {
229: this .lineNum = Number2long(null);
230: }
231: }
232:
233: //
234: // itemId:
235: //
236: public String getItemId() {
237: return this .itemId;
238: }
239:
240: public void setItemId(String itemId) {
241: if (record2().setObject(ICOL_ITEM_ID, itemId)) {
242: this .itemId = itemId;
243: }
244: }
245:
246: public boolean izNullItemId() {
247: return record2().getObject(ICOL_ITEM_ID) == null;
248: }
249:
250: public void setNullItemId() {
251: if (record2().setObject(ICOL_ITEM_ID, null)) {
252: this .itemId = null;
253: }
254: }
255:
256: //
257: // quantity:
258: //
259: public long getQuantity() {
260: return this .quantity;
261: }
262:
263: public void setQuantity(long quantity) {
264: if (record2().setObject(ICOL_QUANTITY, long2Number(quantity))) {
265: this .quantity = quantity;
266: }
267: }
268:
269: public boolean izNullQuantity() {
270: return record2().getObject(ICOL_QUANTITY) == null;
271: }
272:
273: public void setNullQuantity() {
274: if (record2().setObject(ICOL_QUANTITY, null)) {
275: this .quantity = Number2long(null);
276: }
277: }
278:
279: //
280: // unitPrice:
281: //
282: public BigDecimal getUnitPrice() {
283: return this .unitPrice;
284: }
285:
286: public void setUnitPrice(BigDecimal unitPrice) {
287: if (record2().setObject(ICOL_UNIT_PRICE, unitPrice)) {
288: this .unitPrice = unitPrice;
289: }
290: }
291:
292: public boolean izNullUnitPrice() {
293: return record2().getObject(ICOL_UNIT_PRICE) == null;
294: }
295:
296: public void setNullUnitPrice() {
297: if (record2().setObject(ICOL_UNIT_PRICE, null)) {
298: this .unitPrice = null;
299: }
300: }
301:
302: public void toBeanFields() {
303: toBeanFields(this );
304: }
305:
306: public void toBeanFields(PersistentObject from) {
307: orderId = Number2long((Number) from.record2().getObject(
308: ICOL_ORDER_ID));
309: lineNum = Number2long((Number) from.record2().getObject(
310: ICOL_LINE_NUM));
311: itemId = (String) from.record2().getObject(ICOL_ITEM_ID);
312: quantity = Number2long((Number) from.record2().getObject(
313: ICOL_QUANTITY));
314: unitPrice = (BigDecimal) from.record2().getObject(
315: ICOL_UNIT_PRICE);
316: super .toBeanFields(from);
317: }
318:
319: public void fromBeanFields(PersistentObject persistentObject) {
320: LineItemPO from = (LineItemPO) persistentObject;
321: record2().getEntry(ICOL_ORDER_ID).setUnmarkedValue(
322: from.long2Number(orderId), from.long2Number(orderId));
323: record2().getEntry(ICOL_LINE_NUM).setUnmarkedValue(
324: from.long2Number(lineNum), from.long2Number(lineNum));
325: record2().getEntry(ICOL_ITEM_ID).setUnmarkedValue(from.itemId,
326: from.itemId);
327: record2().getEntry(ICOL_QUANTITY).setUnmarkedValue(
328: from.long2Number(quantity), from.long2Number(quantity));
329: record2().getEntry(ICOL_UNIT_PRICE).setUnmarkedValue(
330: from.unitPrice, from.unitPrice);
331: super .fromBeanFieldsDataSaved(persistentObject);
332: }
333:
334: public String toString() {
335:
336: StringBuffer buffer = new StringBuffer();
337: buffer.append("{ " + "class = ").append(
338: this .getClass().getName()).append(" " + "table = ")
339: .append(TABLE_LINE_ITEM).append(" columns = {");
340:
341: if (record() != null) {
342: buffer.append(COL_ORDER_ID).append(" = ").append(
343: record().getObject(ICOL_ORDER_ID)).append(" ");
344: buffer.append(COL_LINE_NUM).append(" = ").append(
345: record().getObject(ICOL_LINE_NUM)).append(" ");
346: buffer.append(COL_ITEM_ID).append(" = ").append(
347: record().getObject(ICOL_ITEM_ID)).append(" ");
348: buffer.append(COL_QUANTITY).append(" = ").append(
349: record().getObject(ICOL_QUANTITY)).append(" ");
350: buffer.append(COL_UNIT_PRICE).append(" = ").append(
351: record().getObject(ICOL_UNIT_PRICE)).append(" ");
352: } else {
353: buffer.append(COL_ORDER_ID).append(" = ").append(orderId)
354: .append(" ");
355: buffer.append(COL_LINE_NUM).append(" = ").append(lineNum)
356: .append(" ");
357: buffer.append(COL_ITEM_ID).append(" = ").append(itemId)
358: .append(" ");
359: buffer.append(COL_QUANTITY).append(" = ").append(quantity)
360: .append(" ");
361: buffer.append(COL_UNIT_PRICE).append(" = ").append(
362: unitPrice).append(" ");
363: }
364: buffer.append("}}");
365: return buffer.toString();
366: }
367:
368: // naturalKey has no context
369:
370: /**
371: * Equals by Basic Peristent object fields (without children objects)
372: */
373: public boolean equalsBasic(Object value) {
374: if (this == value)
375: return true;
376: if (value == null || getClass() != value.getClass())
377: return false;
378:
379: LineItemPO that = (LineItemPO) value;
380:
381: if (orderId != that.orderId)
382: return false;
383: if (lineNum != that.lineNum)
384: return false;
385: if (itemId != null ? !itemId.equals(that.itemId)
386: : that.itemId != null)
387: return false;
388: if (quantity != that.quantity)
389: return false;
390: if (unitPrice != null ? !unitPrice.equals(that.unitPrice)
391: : that.unitPrice != null)
392: return false;
393: return true;
394: }
395:
396: /**
397: * hashCode by Basic Peristent object fields (without children objects)
398: */
399: public int hashCodeBasic() {
400: int result;
401: long temp;
402: result = (int) (orderId ^ (orderId >>> 32));
403: result = 29 * result + (int) (lineNum ^ (lineNum >>> 32));
404: result = 29 * result + (itemId != null ? itemId.hashCode() : 0);
405: result = 29 * result + (int) (quantity ^ (quantity >>> 32));
406: result = 29 * result
407: + (unitPrice != null ? unitPrice.hashCode() : 0);
408:
409: return result;
410: }
411: }
|