`

clob用在dao层

 
阅读更多

public  static String clob2String(Clob fieldName)
   {
  String rtn=null;
  if(fieldName!=null&&!"".equals(fieldName.toString())){
    try {
      rtn=fieldName.getSubString((long)1,(int)fieldName.length());
   } catch (SQLException e) {
    e.printStackTrace();
   }
  }
  return rtn;
   }
 
 public static Clob String2clob(java.sql.Clob clob,String fieldName) throws Exception
   {
  clob=Hibernate.createClob(fieldName);
  return clob;
   }
 public ClobTAcdmNoticeInfo setValuesStringToClob(TAcdmNoticeInfo entity)
 {
  ClobTAcdmNoticeInfo bean = new ClobTAcdmNoticeInfo();
  bean.setId(entity.getId());
  bean.setAddTime(entity.getAddTime());
  bean.setAreaCode(entity.getAreaCode());
  bean.setOrgId(entity.getOrgId());
  bean.setStruts(entity.getStruts());
  bean.setTitle(entity.getTitle());
  bean.setUserId(entity.getUserId());
  try
  {
   String infor = entity.getInformation();
   if(infor == null || "".equals(infor.trim()))
   {
    infor = "_=_";
   }
   bean.setInformation(this.String2clob(bean.getInformation(),infor));
   
  } catch (Exception e) {
   e.printStackTrace();
  }
  return bean;
 }
 
 public TAcdmNoticeInfo setValuesClobToString(ClobTAcdmNoticeInfo entity)
 {
  TAcdmNoticeInfo bean = new TAcdmNoticeInfo();
  bean.setId(entity.getId());
  bean.setAddTime(entity.getAddTime());
  bean.setAreaCode(entity.getAreaCode());
  bean.setOrgId(entity.getOrgId());
  bean.setStruts(entity.getStruts());
  bean.setTitle(entity.getTitle());
  bean.setUserId(entity.getUserId());
  
  String str = this.clob2String(entity.getInformation());
  if ("_=_".equals(str))
  {
   bean.setInformation("");
  }
  else
  {
   bean.setInformation(str);
  }
  
  return bean;
 }
 
  public List findObjectByHQL(String queryString, Object[] values,int current,int pageSize){
   List<ClobTAcdmNoticeInfo> list=super.findObjectByHQL(queryString,values,current,pageSize) ;
   List newList=new ArrayList();
   for(int i=0;i<list.size();i++){
    newList.add(setValuesClobToString(list.get(i)));
   }
   return newList;
   }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics