package pt.isp.iol.gcf.common.customer;
import org.isp.util.GenericValueObject; import org.apache.log4j.Logger;
import java.sql.Timestamp; import java.io.Serializable;
/**
* Created by IntelliJ IDEA.
* User: pfpires
* Date: 22/Set/2003
* Time: 16:24:01
* To change this template use Options | File Templates.
*/
public class CustomerValueObject extends GenericValueObject implements Serializable, Cloneable {
private static final Logger logger = Logger.getLogger( CustomerValueObject.class );
private String customerId;
private String name;
private String billCycle;
private Integer customerType;
private String customerTypeName;
private String state;
private String gtpFlag;
private Timestamp createDate;
private String createdBy;
private Timestamp modificationDate;
private String modifiedBy;
public static final String CustomerVO = CustomerValueObject.class.getName();
public static final String CustomerVOLst = CustomerValueObject.class.getName() + "LST";
public static final String CustomerVOId = CustomerValueObject.class.getName() + "Id";
public static final String CustomerVOState = CustomerValueObject.class.getName() + "Sts";
public static final String CustomerVOHashCode= CustomerValueObject.class.getName() + "HshCd";
public static final String GTPFLAG_T = "T";
public static final String GTPFLAG_F = "F";
public CustomerValueObject(
String customerId,
String name,
String billCycle,
Integer customerType,
String state,
String gtpFlag,
Timestamp createDate,
String createdBy,
Timestamp modificationDate,
String modifiedBy ) {
logger.debug( "CustomerValueObject()" );
this.customerId = customerId;
this.name = name;
this.billCycle = billCycle;
this.customerType = customerType;
this.state = state;
this.gtpFlag = gtpFlag;
this.createDate = createDate;
this.createdBy = createdBy;
this.modificationDate = modificationDate;
this.modifiedBy = modifiedBy;
}public Object clone() throws CloneNotSupportedException {
logger.debug( "clone()" );
CustomerValueObject ret = (CustomerValueObject) super.clone(); // Change this as you need
logger.debug( "cVO clonned:" + ret );
logger.debug( "cVO original:" + this );
return ret;
}
public CustomerValueObject(
String customerId,
String name,
String state,
String createdBy,
String modifiedBy,
Integer customerType
) {
logger.debug( "CustomerValueObject()" );
this.customerId = customerId;
this.name = name;
this.customerType = customerType;
this.state = state;
this.createdBy = createdBy;
this.modifiedBy = modifiedBy;
} public CustomerValueObject() {
} public String getCustomerId() {
return customerId;
} public void setCustomerId( Integer customer_id ) {
logger.debug( "setCustomerId()" );
this.customerId = customer_id.toString();
} public void setCustomerId( String customer_id ) {
logger.debug( "setCustomerId()" );
this.customerId = customer_id;
} public String getName() {
return name;
} public void setName( String name ) {
logger.debug( "setName()" );
this.name = name;
} public String getBillCycle() {
return billCycle;
} public void setBillCycle( String billCycle ) {
logger.debug( "setBillCycle()" );
this.billCycle = billCycle;
} public Integer getCustomerType() {
return customerType;
} public void setCustomerType( Integer customerType ) {
logger.debug( "setCustomerType()" );
this.customerType = customerType;
} public void setCustomerType( String customerType ) {
logger.debug( "setCustomerType()" );
try {
this.customerType = new Integer(customerType);
} catch ( NumberFormatException e ) {
logger.debug( "setCustomerType() - NumberFormatException" );
this.customerType = null;
}
} public String getState() {
return state;
} public void setState( String state ) {
logger.debug( "setState()" );
this.state = state;
} public String getGtpFlag() {
return gtpFlag;
} public void setGtpFlag( String gtpFlag ) {
logger.debug( "setGtpFlag()" );
this.gtpFlag = gtpFlag;
} public Timestamp getCreateDate() {
return createDate;
} public void setCreateDate( Timestamp createDate ) {
logger.debug( "setCreateDate()" );
this.createDate = createDate;
} public String getCreatedBy() {
return createdBy;
} public void setCreatedBy( String createdBy ) {
logger.debug( "setCreatedBy()" );
this.createdBy = createdBy;
} public Timestamp getModificationDate() {
return modificationDate;
} public void setModificationDate( Timestamp modificationDate ) {
logger.debug( "setModificationDate()" );
this.modificationDate = modificationDate;
} public String getModifiedBy() {
return modifiedBy;
} public void setModifiedBy( String modifiedBy ) {
logger.debug( "setModifiedBy()" );
this.modifiedBy = modifiedBy;
} public boolean equalsGcf2Gtp( final CustomerValueObject customer ) {
if ( this == customer ) return true;if ( customerId != null ? !customerId.equals( customer.customerId ) : customer.customerId != null ) return false;
if ( name != null ? !name.equals( customer.name ) : customer.name != null ) return false;
if ( billCycle != null ? !billCycle.equals( customer.billCycle ) : customer.billCycle != null ) return false;
if ( customerType != null ? !customerType.equals( customer.customerType ) : customer.customerType != null ) return false;
if ( state != null ? !state.equals( customer.state ) : customer.state != null ) return false;
return true; }
public boolean equals( Object o ) {
if ( this == o ) return true;
if ( !( o instanceof CustomerValueObject ) ) return false;final CustomerValueObject customerValueObject = (CustomerValueObject) o;
if ( billCycle != null ?
!billCycle.equals( customerValueObject.billCycle ) : customerValueObject.billCycle != null ) {
return false;
}
if ( createDate != null ?
!createDate.equals( customerValueObject.createDate ) : customerValueObject.createDate != null ) {
return false;
}
if ( createdBy != null ?
!createdBy.equals( customerValueObject.createdBy ) : customerValueObject.createdBy != null ) {
return false;
}
if ( customerId != null ?
!customerId.equals( customerValueObject.customerId ) : customerValueObject.customerId != null ) {
return false;
}
if ( customerType != null ?
!customerType.equals( customerValueObject.customerType ) : customerValueObject.customerType != null ) {
return false;
}
if ( gtpFlag != null ? !gtpFlag.equals( customerValueObject.gtpFlag ) : customerValueObject.gtpFlag != null ) return false;
if ( modificationDate != null ?
!modificationDate.equals( customerValueObject.modificationDate ) :
customerValueObject.modificationDate != null ) {
return false;
}
if ( modifiedBy != null ?
!modifiedBy.equals( customerValueObject.modifiedBy ) : customerValueObject.modifiedBy != null ) {
return false;
}
if ( name != null ? !name.equals( customerValueObject.name ) : customerValueObject.name != null ) return false;
if ( state != null ? !state.equals( customerValueObject.state ) : customerValueObject.state != null ) return false;
return true; }
public int hashCode() {
int result;
result = ( customerId != null ? customerId.hashCode() : 0 );
result = 29 * result + ( name != null ? name.hashCode() : 0 );
result = 29 * result + ( billCycle != null ? billCycle.hashCode() : 0 );
result = 29 * result + ( customerType != null ? customerType.hashCode() : 0 );
result = 29 * result + ( state != null ? state.hashCode() : 0 );
result = 29 * result + ( gtpFlag != null ? gtpFlag.hashCode() : 0 );
result = 29 * result + ( createDate != null ? createDate.hashCode() : 0 );
result = 29 * result + ( createdBy != null ? createdBy.hashCode() : 0 );
result = 29 * result + ( modificationDate != null ? modificationDate.hashCode() : 0 );
result = 29 * result + ( modifiedBy != null ? modifiedBy.hashCode() : 0 );
return result;
}
public int hashCode( String _state ) {
int result;
result = ( customerId != null ? customerId.hashCode() : 0 );
result = 29 * result + ( name != null ? name.hashCode() : 0 );
result = 29 * result + ( billCycle != null ? billCycle.hashCode() : 0 );
result = 29 * result + ( customerType != null ? customerType.hashCode() : 0 );
result = 29 * result + ( _state != null ? _state.hashCode() : 0 );
result = 29 * result + ( createDate != null ? createDate.hashCode() : 0 );
result = 29 * result + ( createdBy != null ? createdBy.hashCode() : 0 );
return result;
}
}
Jos� Fortunato H. Tom�s wrote:
Just fo help I'm adding the following inspection by SQL:
Oracle Sql Query: desc Customer result;
Output:
Nome Nulo? Tipo
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CUSTOMER_ID NOT NULL NUMBER(8)
CUSTOMER_NAME VARCHAR2(120)
BILL_CYCLE VARCHAR2(2)
CUSTOMER_TYPE NUMBER
STATUS VARCHAR2(1)
GTP_FLAG VARCHAR2(1)
CREATE_DATE DATE
CREATED_BY VARCHAR2(32)
MODIFICATION_DATE DATE
MODIFIED_BY VARCHAR2(32)
Jos� Fortunato H. Tom�s wrote:
I have the following problem:
Bean setter for an Oracle DB table's collumn of type NUMBER isn't called.
To parcially solve I had to use to_char SQL directive:
--->
QueryRunner run = new QueryRunner( GcfServiceLocator.getInstance().getDataSourceForGCF() );
BeanListHandler bh = new BeanListHandler( CustomerValueObject.class );
Object[] args = {( "%" + name + "%" ).replaceAll( "\\s", "%" ).replaceAll( "%{2,}", "%" )};
query = "select" +
" to_char(CUSTOMER_ID) customerId" +
", CUSTOMER_NAME name" +
", BILL_CYCLE billCycle" +
", to_char(CUSTOMER_TYPE) customerType" +
", STATUS state" +
", GTP_FLAG gtpFlag" +
", CREATE_DATE createDate" +
", CREATED_BY createdBy" +
", MODIFICATION_DATE modificationDate" +
", MODIFIED_BY modifiedBy" +
" from CUSTOMER" +
" where" +
" CUSTOMER_NAME LIKE ?1"
;
logger.debug( "getCustomerListByName(" + query + ")" );
ret = (ArrayList)run.query(
query
, args
, bh
);
<---
I looked into the source, but for lack of time I could't found the correct place that maps props types and collunms between setters for lookup method by reflection.
Is there a known issue ? What can I do? Is there any code that I can aplly? Or can you give-me an indication into the source so I contribute fastly?
Thanks!
--
__________________________________________________
Jos� Fortunato Tom�s
*Mediacapital** Telecomunica��es - IOL*
Rua M�rio Castelhano n� 40
2749-502 BARCARENA
Ext.: 12733
Telef.: 21 434 59 33
Fax.: 21 434 63 88
