public <T>T param2PO(Class<T> type,Object param,T po,User currentUser) throws Exception {
  Long createdBy;
  Long lastModifiedBy;
  Field idField=type.getDeclaredField(CommonsConstant.ID);
  idField.setAccessible(true);
  Field createdByField=type.getDeclaredField(CommonsConstant.CREATED_BY);
  createdByField.setAccessible(true);
  Field lastModifiedByField=type.getDeclaredField(CommonsConstant.LAST_MODIFIED_BY);
  lastModifiedByField.setAccessible(true);
  Field lastModifiedDateField=type.getDeclaredField(CommonsConstant.LAST_MODIFIED_DATE);
  lastModifiedDateField.setAccessible(true);
  Date now=new Date();
  if (idField.get(po) == null) {
    createdBy=currentUser.getId();
    lastModifiedBy=createdBy;
  }
 else {
    createdBy=(Long)createdByField.get(po);
    lastModifiedBy=currentUser.getId();
  }
  BeanUtils.copyPropertiesIgnoreNull(param,po);
  createdByField.set(po,createdBy);
  lastModifiedByField.set(po,lastModifiedBy);
  lastModifiedDateField.set(po,now);
  return po;
}

public < T > T param2PO ( Class < T > type , Object param , T po , User currentUser ) throws Exception { Long createdBy ; Long lastModifiedBy ; Field idField = type . getDeclaredField ( CommonsConstant . ID ) ; idField . setAccessible ( true ) ; Field createdByField = type . getDeclaredField ( CommonsConstant . CREATED_BY ) ; createdByField . setAccessible ( true ) ; Field lastModifiedByField = type . getDeclaredField ( CommonsConstant . LAST_MODIFIED_BY ) ; lastModifiedByField . setAccessible ( true ) ; Field lastModifiedDateField = type . getDeclaredField ( CommonsConstant . LAST_MODIFIED_DATE ) ; lastModifiedDateField . setAccessible ( true ) ; Date now = new Date ( ) ; if ( idField . get ( po ) == null ) { createdBy = currentUser . getId ( ) ; lastModifiedBy = createdBy ; } else { createdBy = ( Long ) createdByField . get ( po ) ; lastModifiedBy = currentUser . getId ( ) ; } BeanUtils . copyPropertiesIgnoreNull ( param , po ) ; createdByField . set ( po , createdBy ) ; lastModifiedByField . set ( po , lastModifiedBy ) ; lastModifiedDateField . set ( po , now ) ; return po ; }
transform param to po .
