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.ICustomerContactRel;
018:
019: public class CustomerContactRelPO extends PersistentObject implements
020: ICustomerContactRel, 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_CUSTOMER_CONTACT_REL = "CUSTOMER_CONTACT_REL";
052:
053: public CustomerContactRelPO() {
054: super (new Record(table));
055: }
056:
057: public CustomerContactRelPO(Long contactId, String contactType,
058: Long customerId) {
059: this ();
060: setContactId(contactId);
061: setContactType(contactType);
062: setCustomerId(customerId);
063: }
064:
065: public static final String COL_CUSTOMER_ID = "CUSTOMER_ID";
066: public static final String TCOL_CUSTOMER_ID = "CUSTOMER_CONTACT_REL.CUSTOMER_ID";
067: public static final int ICOL_CUSTOMER_ID = 0;
068: public static final int JDBC_TYPE_CUSTOMER_ID = -5;
069:
070: public static final String COL_CONTACT_ID = "CONTACT_ID";
071: public static final String TCOL_CONTACT_ID = "CUSTOMER_CONTACT_REL.CONTACT_ID";
072: public static final int ICOL_CONTACT_ID = 1;
073: public static final int JDBC_TYPE_CONTACT_ID = -5;
074:
075: public static final String COL_CONTACT_TYPE = "CONTACT_TYPE";
076: public static final String TCOL_CONTACT_TYPE = "CUSTOMER_CONTACT_REL.CONTACT_TYPE";
077: public static final int ICOL_CONTACT_TYPE = 2;
078: public static final int JDBC_TYPE_CONTACT_TYPE = 12;
079:
080: private static final MetaTable table = new MetaTable(
081: "CUSTOMER_CONTACT_REL", "CUSTOMER_CONTACT_REL", 3, 3);
082:
083: static {
084: table.setStaticFinal(true);
085: //
086: // Meta Foreign Keys:
087: //
088: table.addToForeignKey("CONTACT", new ForeignKeyEntry(
089: "CONTACT_ID", "CONTACT_ID"));
090: table.addToForeignKey("CUSTOMER", new ForeignKeyEntry(
091: "CUSTOMER_ID", "CUSTOMER_ID"));
092: //
093: // Meta Natural Key:
094: //
095: // naturalKey has no context
096:
097: //
098: // Meta Columns:
099: //
100:
101: final MetaColumn metaCustomerId = new MetaColumn(
102: ICOL_CUSTOMER_ID, "CUSTOMER_ID", "CUSTOMER_ID", table);
103: metaCustomerId.setPrimaryKey(true);
104: metaCustomerId.setRequired(true);
105: metaCustomerId.setOptimisticLock(false);
106: metaCustomerId.setType(ColumnType.LONG);
107: metaCustomerId.setColumnSize(0);
108: metaCustomerId.setRemarks("");
109: metaCustomerId.setDecimalDigits(0);
110: metaCustomerId.setAutoGenerated(false);
111: metaCustomerId.setAutoIncrement(false);
112: metaCustomerId.setJdbcType(-5);
113: table.addToPrimaryKey(new Integer(ICOL_CUSTOMER_ID));
114: table.addColumn(metaCustomerId);
115:
116: final MetaColumn metaContactId = new MetaColumn(
117: ICOL_CONTACT_ID, "CONTACT_ID", "CONTACT_ID", table);
118: metaContactId.setPrimaryKey(true);
119: metaContactId.setRequired(true);
120: metaContactId.setOptimisticLock(false);
121: metaContactId.setType(ColumnType.LONG);
122: metaContactId.setColumnSize(0);
123: metaContactId.setRemarks("");
124: metaContactId.setDecimalDigits(0);
125: metaContactId.setAutoGenerated(false);
126: metaContactId.setAutoIncrement(false);
127: metaContactId.setJdbcType(-5);
128: table.addToPrimaryKey(new Integer(ICOL_CONTACT_ID));
129: table.addColumn(metaContactId);
130:
131: final MetaColumn metaContactType = new MetaColumn(
132: ICOL_CONTACT_TYPE, "CONTACT_TYPE", "CONTACT_TYPE",
133: table);
134: metaContactType.setPrimaryKey(true);
135: metaContactType.setRequired(true);
136: metaContactType.setOptimisticLock(false);
137: metaContactType.setType(ColumnType.STRING);
138: metaContactType.setColumnSize(40);
139: metaContactType.setRemarks("");
140: metaContactType.setDecimalDigits(0);
141: metaContactType.setAutoGenerated(false);
142: metaContactType.setAutoIncrement(false);
143: metaContactType.setJdbcType(12);
144: table.addToPrimaryKey(new Integer(ICOL_CONTACT_TYPE));
145: table.addColumn(metaContactType);
146:
147: }
148:
149: private Long customerId;
150: private Long contactId;
151: private String contactType;
152:
153: //
154: // customerId:
155: //
156: public Long getCustomerId() {
157: return this .customerId;
158: }
159:
160: public void setCustomerId(Long customerId) {
161: if (record2().setObject(ICOL_CUSTOMER_ID, customerId)) {
162: this .customerId = customerId;
163: }
164: }
165:
166: public boolean izNullCustomerId() {
167: return record2().getObject(ICOL_CUSTOMER_ID) == null;
168: }
169:
170: public void setNullCustomerId() {
171: if (record2().setObject(ICOL_CUSTOMER_ID, null)) {
172: this .customerId = null;
173: }
174: }
175:
176: //
177: // contactId:
178: //
179: public Long getContactId() {
180: return this .contactId;
181: }
182:
183: public void setContactId(Long contactId) {
184: if (record2().setObject(ICOL_CONTACT_ID, contactId)) {
185: this .contactId = contactId;
186: }
187: }
188:
189: public boolean izNullContactId() {
190: return record2().getObject(ICOL_CONTACT_ID) == null;
191: }
192:
193: public void setNullContactId() {
194: if (record2().setObject(ICOL_CONTACT_ID, null)) {
195: this .contactId = null;
196: }
197: }
198:
199: //
200: // contactType:
201: //
202: public String getContactType() {
203: return this .contactType;
204: }
205:
206: public void setContactType(String contactType) {
207: if (record2().setObject(ICOL_CONTACT_TYPE, contactType)) {
208: this .contactType = contactType;
209: }
210: }
211:
212: public boolean izNullContactType() {
213: return record2().getObject(ICOL_CONTACT_TYPE) == null;
214: }
215:
216: public void setNullContactType() {
217: if (record2().setObject(ICOL_CONTACT_TYPE, null)) {
218: this .contactType = null;
219: }
220: }
221:
222: public void toBeanFields() {
223: toBeanFields(this );
224: }
225:
226: public void toBeanFields(PersistentObject from) {
227: customerId = (Long) from.record2().getObject(ICOL_CUSTOMER_ID);
228: contactId = (Long) from.record2().getObject(ICOL_CONTACT_ID);
229: contactType = (String) from.record2().getObject(
230: ICOL_CONTACT_TYPE);
231: super .toBeanFields(from);
232: }
233:
234: public void fromBeanFields(PersistentObject persistentObject) {
235: CustomerContactRelPO from = (CustomerContactRelPO) persistentObject;
236: record2().getEntry(ICOL_CUSTOMER_ID).setUnmarkedValue(
237: from.customerId, from.customerId);
238: record2().getEntry(ICOL_CONTACT_ID).setUnmarkedValue(
239: from.contactId, from.contactId);
240: record2().getEntry(ICOL_CONTACT_TYPE).setUnmarkedValue(
241: from.contactType, from.contactType);
242: super .fromBeanFieldsDataSaved(persistentObject);
243: }
244:
245: public String toString() {
246:
247: StringBuffer buffer = new StringBuffer();
248: buffer.append("{ " + "class = ").append(
249: this .getClass().getName()).append(" " + "table = ")
250: .append(TABLE_CUSTOMER_CONTACT_REL).append(
251: " columns = {");
252:
253: if (record() != null) {
254: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
255: record().getObject(ICOL_CUSTOMER_ID)).append(" ");
256: buffer.append(COL_CONTACT_ID).append(" = ").append(
257: record().getObject(ICOL_CONTACT_ID)).append(" ");
258: buffer.append(COL_CONTACT_TYPE).append(" = ").append(
259: record().getObject(ICOL_CONTACT_TYPE)).append(" ");
260: } else {
261: buffer.append(COL_CUSTOMER_ID).append(" = ").append(
262: customerId).append(" ");
263: buffer.append(COL_CONTACT_ID).append(" = ").append(
264: contactId).append(" ");
265: buffer.append(COL_CONTACT_TYPE).append(" = ").append(
266: contactType).append(" ");
267: }
268: buffer.append("}}");
269: return buffer.toString();
270: }
271:
272: // naturalKey has no context
273:
274: /**
275: * Equals by Basic Peristent object fields (without children objects)
276: */
277: public boolean equalsBasic(Object value) {
278: if (this == value)
279: return true;
280: if (value == null || getClass() != value.getClass())
281: return false;
282:
283: CustomerContactRelPO that = (CustomerContactRelPO) value;
284:
285: if (customerId != null ? !customerId.equals(that.customerId)
286: : that.customerId != null)
287: return false;
288: if (contactId != null ? !contactId.equals(that.contactId)
289: : that.contactId != null)
290: return false;
291: if (contactType != null ? !contactType.equals(that.contactType)
292: : that.contactType != null)
293: return false;
294: return true;
295: }
296:
297: /**
298: * hashCode by Basic Peristent object fields (without children objects)
299: */
300: public int hashCodeBasic() {
301: int result;
302: long temp;
303: result = (customerId != null ? customerId.hashCode() : 0);
304: result = 29 * result
305: + (contactId != null ? contactId.hashCode() : 0);
306: result = 29 * result
307: + (contactType != null ? contactType.hashCode() : 0);
308:
309: return result;
310: }
311: }
|