CustomerPO.java :  » Database-ORM » ODAL » com » completex » objective » persistency » examples » ex004 » pos » Java Open Source

Java Open Source » Database ORM » ODAL 
ODAL » com » completex » objective » persistency » examples » ex004 » pos » CustomerPO.java
/**
 * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
 */
package com.completex.objective.persistency.examples.ex004.pos;

import com.completex.objective.components.persistency.key.impl.DefaultNaturalKeyFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Clob;
import java.sql.Blob;
import com.completex.objective.components.persistency.*;
import com.completex.objective.components.persistency.key.impl.DefaultNaturalKeyFactory;


import java.util.Date;

public class CustomerPO extends PersistentObject  implements java.io.Externalizable {
    //
    // Complex object related:
    //

    //
    private static Map registeredMasters;
    private static Object lock = new Object();

    protected Object classLock() {
        return lock;
    }

    protected void instantiateRegisteredMasters() {
        if (registeredMasters == null) {
            synchronized (lock) {
                if (registeredMasters == null) {
                    registeredMasters = new HashMap();
                }
            }
        }
    }

    protected Map registeredMasters() {
        return registeredMasters;
    }
    //
    //
    //

    public static final String TABLE_CUSTOMER = "CUSTOMER";

    public CustomerPO() {
        super(new Record(table));
    }

    public CustomerPO(Long customerId) {
        this();
        setCustomerId(customerId);
    }

    public static final String COL_CUSTOMER_ID = "CUSTOMER_ID";
    public static final String TCOL_CUSTOMER_ID = "CUSTOMER.CUSTOMER_ID";
    public static final int ICOL_CUSTOMER_ID = 0;
    public static final int JDBC_TYPE_CUSTOMER_ID = -5;

    public static final String COL_CONTACT_ID = "CONTACT_ID";
    public static final String TCOL_CONTACT_ID = "CUSTOMER.CONTACT_ID";
    public static final int ICOL_CONTACT_ID = 1;
    public static final int JDBC_TYPE_CONTACT_ID = -5;

    public static final String COL_ORG_NAME = "ORG_NAME";
    public static final String TCOL_ORG_NAME = "CUSTOMER.ORG_NAME";
    public static final int ICOL_ORG_NAME = 2;
    public static final int JDBC_TYPE_ORG_NAME = 12;

    public static final String COL_URL = "URL";
    public static final String TCOL_URL = "CUSTOMER.URL";
    public static final int ICOL_URL = 3;
    public static final int JDBC_TYPE_URL = 12;

    public static final String COL_LAST_UPDATED = "LAST_UPDATED";
    public static final String TCOL_LAST_UPDATED = "CUSTOMER.LAST_UPDATED";
    public static final int ICOL_LAST_UPDATED = 4;
    public static final int JDBC_TYPE_LAST_UPDATED = 91;

    public static final String COL_CREATION_DATE = "CREATION_DATE";
    public static final String TCOL_CREATION_DATE = "CUSTOMER.CREATION_DATE";
    public static final int ICOL_CREATION_DATE = 5;
    public static final int JDBC_TYPE_CREATION_DATE = 91;


    private static final MetaTable table = new MetaTable("CUSTOMER", "CUSTOMER", 6, 1);
        
    static {
        table.setStaticFinal(true);
        //
        // Meta Foreign Keys:
        //
        table.addToForeignKey("CONTACT", new ForeignKeyEntry("CONTACT_ID", "CONTACT_ID"));
        //
        // Meta Natural Key:
        //
        // naturalKey has no context 
    
        //
        // Meta Columns:
        //

        final MetaColumn metaCustomerId = new MetaColumn(ICOL_CUSTOMER_ID,
                    "CUSTOMER_ID",
                    "CUSTOMER_ID",
                    table);
        metaCustomerId.setPrimaryKey(true);
        metaCustomerId.setRequired(true);
        metaCustomerId.setOptimisticLock(false);
        metaCustomerId.setType(ColumnType.LONG);
        metaCustomerId.setColumnSize(0);
        metaCustomerId.setRemarks("");
        metaCustomerId.setDecimalDigits(0);
        metaCustomerId.setAutoGenerated(true);
        metaCustomerId.setAutoIncrement(false);
        metaCustomerId.setJdbcType(-5);
        metaCustomerId.setKeyGenerator(new com.completex.objective.components.persistency.key.impl.SimpleSequenceKeyGeneratorImpl());
        {
            HashMap staticAttributes = new HashMap();
            staticAttributes.put("name", "CUSTOMER_SEQ");
            metaCustomerId.setGeneratorStaticAttributes(staticAttributes);
        }
        metaCustomerId.initializeKeyGenerator();
        table.addToPrimaryKey(new Integer(ICOL_CUSTOMER_ID));
        table.addColumn(metaCustomerId);


        final MetaColumn metaContactId = new MetaColumn(ICOL_CONTACT_ID,
                    "CONTACT_ID",
                    "CONTACT_ID",
                    table);
        metaContactId.setPrimaryKey(false);
        metaContactId.setRequired(true);
        metaContactId.setOptimisticLock(false);
        metaContactId.setType(ColumnType.LONG);
        metaContactId.setColumnSize(0);
        metaContactId.setRemarks("");
        metaContactId.setDecimalDigits(0);
        metaContactId.setAutoGenerated(false);
        metaContactId.setAutoIncrement(false);
        metaContactId.setJdbcType(-5);
        table.addColumn(metaContactId);


        final MetaColumn metaOrgName = new MetaColumn(ICOL_ORG_NAME,
                    "ORG_NAME",
                    "ORG_NAME",
                    table);
        metaOrgName.setPrimaryKey(false);
        metaOrgName.setRequired(true);
        metaOrgName.setOptimisticLock(false);
        metaOrgName.setType(ColumnType.STRING);
        metaOrgName.setColumnSize(40);
        metaOrgName.setRemarks("");
        metaOrgName.setDecimalDigits(0);
        metaOrgName.setAutoGenerated(false);
        metaOrgName.setAutoIncrement(false);
        metaOrgName.setJdbcType(12);
        table.addColumn(metaOrgName);


        final MetaColumn metaUrl = new MetaColumn(ICOL_URL,
                    "URL",
                    "URL",
                    table);
        metaUrl.setPrimaryKey(false);
        metaUrl.setRequired(true);
        metaUrl.setOptimisticLock(false);
        metaUrl.setType(ColumnType.STRING);
        metaUrl.setColumnSize(40);
        metaUrl.setRemarks("");
        metaUrl.setDecimalDigits(0);
        metaUrl.setAutoGenerated(false);
        metaUrl.setAutoIncrement(false);
        metaUrl.setJdbcType(12);
        table.addColumn(metaUrl);


        final MetaColumn metaLastUpdated = new MetaColumn(ICOL_LAST_UPDATED,
                    "LAST_UPDATED",
                    "LAST_UPDATED",
                    table);
        metaLastUpdated.setPrimaryKey(false);
        metaLastUpdated.setRequired(false);
        metaLastUpdated.setOptimisticLock(false);
        metaLastUpdated.setType(ColumnType.DATE);
        metaLastUpdated.setColumnSize(0);
        metaLastUpdated.setRemarks("");
        metaLastUpdated.setDecimalDigits(0);
        metaLastUpdated.setAutoGenerated(true);
        metaLastUpdated.setAutoIncrement(false);
        metaLastUpdated.setJdbcType(91);
        metaLastUpdated.setKeyGenerator(new com.completex.objective.components.persistency.key.impl.LastUpdatedDateGenerator());
        metaLastUpdated.initializeKeyGenerator();
        table.addColumn(metaLastUpdated);


        final MetaColumn metaCreationDate = new MetaColumn(ICOL_CREATION_DATE,
                    "CREATION_DATE",
                    "CREATION_DATE",
                    table);
        metaCreationDate.setPrimaryKey(false);
        metaCreationDate.setRequired(false);
        metaCreationDate.setOptimisticLock(false);
        metaCreationDate.setType(ColumnType.DATE);
        metaCreationDate.setColumnSize(0);
        metaCreationDate.setRemarks("");
        metaCreationDate.setDecimalDigits(0);
        metaCreationDate.setAutoGenerated(true);
        metaCreationDate.setAutoIncrement(false);
        metaCreationDate.setJdbcType(91);
        metaCreationDate.setKeyGenerator(new com.completex.objective.components.persistency.key.impl.CreatedDateGenerator());
        metaCreationDate.initializeKeyGenerator();
        table.addColumn(metaCreationDate);

    }

    private Long customerId;
    private Long contactId;
    private String orgName;
    private String url;
    private Date lastUpdated;
    private Date creationDate;


    //
    // customerId:
    //
    public Long getCustomerId() {
        return this.customerId;
    }

    public void setCustomerId(Long customerId) {
         if (record2().setObject(ICOL_CUSTOMER_ID, customerId)) {
             this.customerId = customerId;
         }
    }

    public boolean izNullCustomerId() {
        return record2().getObject(ICOL_CUSTOMER_ID) == null;
    }

    public void setNullCustomerId() {
         if (record2().setObject(ICOL_CUSTOMER_ID, null)) {
             this.customerId = null;
         }
    }


    //
    // contactId:
    //
    public Long getContactId() {
        return this.contactId;
    }

    public void setContactId(Long contactId) {
         if (record2().setObject(ICOL_CONTACT_ID, contactId)) {
             this.contactId = contactId;
         }
    }

    public boolean izNullContactId() {
        return record2().getObject(ICOL_CONTACT_ID) == null;
    }

    public void setNullContactId() {
         if (record2().setObject(ICOL_CONTACT_ID, null)) {
             this.contactId = null;
         }
    }


    //
    // orgName:
    //
    public String getOrgName() {
        return this.orgName;
    }

    public void setOrgName(String orgName) {
         if (record2().setObject(ICOL_ORG_NAME, orgName)) {
             this.orgName = orgName;
         }
    }

    public boolean izNullOrgName() {
        return record2().getObject(ICOL_ORG_NAME) == null;
    }

    public void setNullOrgName() {
         if (record2().setObject(ICOL_ORG_NAME, null)) {
             this.orgName = null;
         }
    }


    //
    // url:
    //
    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
         if (record2().setObject(ICOL_URL, url)) {
             this.url = url;
         }
    }

    public boolean izNullUrl() {
        return record2().getObject(ICOL_URL) == null;
    }

    public void setNullUrl() {
         if (record2().setObject(ICOL_URL, null)) {
             this.url = null;
         }
    }


    //
    // lastUpdated:
    //
    public Date getLastUpdated() {
        return this.lastUpdated;
    }

    public void setLastUpdated(Date lastUpdated) {
         if (record2().setObject(ICOL_LAST_UPDATED, lastUpdated)) {
             this.lastUpdated = lastUpdated;
         }
    }

    public boolean izNullLastUpdated() {
        return record2().getObject(ICOL_LAST_UPDATED) == null;
    }

    public void setNullLastUpdated() {
         if (record2().setObject(ICOL_LAST_UPDATED, null)) {
             this.lastUpdated = null;
         }
    }


    //
    // creationDate:
    //
    public Date getCreationDate() {
        return this.creationDate;
    }

    public void setCreationDate(Date creationDate) {
         if (record2().setObject(ICOL_CREATION_DATE, creationDate)) {
             this.creationDate = creationDate;
         }
    }

    public boolean izNullCreationDate() {
        return record2().getObject(ICOL_CREATION_DATE) == null;
    }

    public void setNullCreationDate() {
         if (record2().setObject(ICOL_CREATION_DATE, null)) {
             this.creationDate = null;
         }
    }


    public void toBeanFields() {
        toBeanFields(this);
    }

    public void toBeanFields(PersistentObject from) {
        customerId = (Long) from.record2().getObject(ICOL_CUSTOMER_ID);
        contactId = (Long) from.record2().getObject(ICOL_CONTACT_ID);
        orgName = (String) from.record2().getObject(ICOL_ORG_NAME);
        url = (String) from.record2().getObject(ICOL_URL);
        lastUpdated = (Date) from.record2().getObject(ICOL_LAST_UPDATED);
        creationDate = (Date) from.record2().getObject(ICOL_CREATION_DATE);
        super.toBeanFields(from);
    }


    public void fromBeanFields(PersistentObject persistentObject) {
        CustomerPO from = (CustomerPO) persistentObject;
        record2().getEntry(ICOL_CUSTOMER_ID).setUnmarkedValue(from.customerId, from.customerId);
        record2().getEntry(ICOL_CONTACT_ID).setUnmarkedValue(from.contactId, from.contactId);
        record2().getEntry(ICOL_ORG_NAME).setUnmarkedValue(from.orgName, from.orgName);
        record2().getEntry(ICOL_URL).setUnmarkedValue(from.url, from.url);
        record2().getEntry(ICOL_LAST_UPDATED).setUnmarkedValue(from.lastUpdated, from.lastUpdated);
        record2().getEntry(ICOL_CREATION_DATE).setUnmarkedValue(from.creationDate, from.creationDate);
        super.fromBeanFieldsDataSaved(persistentObject);
    }

    public String toString() {

        StringBuffer buffer = new StringBuffer();
        buffer.append("{ " + "class = ")
                .append(this.getClass().getName())
                .append(" " + "table = ")
                .append(TABLE_CUSTOMER)
                .append(" columns = {");

        if (record() != null) {
            buffer.append(COL_CUSTOMER_ID).append(" = ").append(record().getObject(ICOL_CUSTOMER_ID)).append(" ");
            buffer.append(COL_CONTACT_ID).append(" = ").append(record().getObject(ICOL_CONTACT_ID)).append(" ");
            buffer.append(COL_ORG_NAME).append(" = ").append(record().getObject(ICOL_ORG_NAME)).append(" ");
            buffer.append(COL_URL).append(" = ").append(record().getObject(ICOL_URL)).append(" ");
            buffer.append(COL_LAST_UPDATED).append(" = ").append(record().getObject(ICOL_LAST_UPDATED)).append(" ");
            buffer.append(COL_CREATION_DATE).append(" = ").append(record().getObject(ICOL_CREATION_DATE)).append(" ");
        } else {
            buffer.append(COL_CUSTOMER_ID).append(" = ").append(customerId).append(" ");
            buffer.append(COL_CONTACT_ID).append(" = ").append(contactId).append(" ");
            buffer.append(COL_ORG_NAME).append(" = ").append(orgName).append(" ");
            buffer.append(COL_URL).append(" = ").append(url).append(" ");
            buffer.append(COL_LAST_UPDATED).append(" = ").append(lastUpdated).append(" ");
            buffer.append(COL_CREATION_DATE).append(" = ").append(creationDate).append(" ");
        }
        buffer.append("}}");
        return buffer.toString();
    }
    
    // naturalKey has no context 
    
    
    /**
     * Equals by Basic Peristent object fields (without children objects)
     */
    public boolean equalsBasic(Object value) {
        if (this == value) return true;
        if (value == null || getClass() != value.getClass()) return false;
        
        CustomerPO that = (CustomerPO) value;
        
        if (customerId != null ? !customerId.equals(that.customerId) : that.customerId != null) return false;
        if (contactId != null ? !contactId.equals(that.contactId) : that.contactId != null) return false;
        if (orgName != null ? !orgName.equals(that.orgName) : that.orgName != null) return false;
        if (url != null ? !url.equals(that.url) : that.url != null) return false;
        if (lastUpdated != null ? !lastUpdated.equals(that.lastUpdated) : that.lastUpdated != null) return false;
        if (creationDate != null ? !creationDate.equals(that.creationDate) : that.creationDate != null) return false;
        return true;
    }
    
    
    /**
     * hashCode by Basic Peristent object fields (without children objects)
     */
    public int hashCodeBasic() {
        int result;
        long temp;
        result =  (customerId != null ? customerId.hashCode() : 0);
        result = 29 * result + (contactId != null ? contactId.hashCode() : 0);
        result = 29 * result + (orgName != null ? orgName.hashCode() : 0);
        result = 29 * result + (url != null ? url.hashCode() : 0);
        result = 29 * result + (lastUpdated != null ? lastUpdated.hashCode() : 0);
        result = 29 * result + (creationDate != null ? creationDate.hashCode() : 0);
        
        return result;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.