我的解决hibernate中clob之道

 session = HibernateSessionFactory.currentSession();
   session.lock(pe,LockMode.NONE);
   pe.setLastFailReason("");
   if (pe.getProtocolType() == 0) {
    // logger.error(pe.getId().toString() + "扫描前的pop3id列表 " +
    // pe.getPopUidList());
    pop3Scan(pe);
   } else if (pe.getProtocolType() == 1) {
    imapScan(pe);
   } else {
    logger.error("|" + pe.getId().getUsernumber() + "|" + "协议类型错 "
      + "|Protocol_type :" + pe.getProtocolType() + "|");
   }
   Transaction tx = null;
   // session.isOpen()
   tx = session.beginTransaction();
   // logger.error(pe.getId().toString() + "扫描后的pop3id列表 " +
   // pe.getPopUidList());
   pe.setInquireState(0l);
   pe.setLastScanTime(new java.util.Date());
   session.update(pe);
   session.flush();
//   为更新pop3uid
   logger.info("handle 1111111111");
   session.refresh(pe, LockMode.UPGRADE); //grabs an Oracle CLOB  
  // oracle.sql.CLOB clob = (oracle.sql.CLOB)((SerializableClob)pe.getPopUidListClob()).getWrappedClob();  
//   注:如果是用weblogic connection pool,则用weblogic的OracleThinClob  
   logger.info("handle 2222222222");
   pe.setPopUidListClob(Hibernate.createClob(pe.getPopUidList() + "  "));
   /*
   java.io.Writer pw = clob.getCharacterOutputStream();  
   pw.write(pe.getPopUidList() + "  ");  
   pw.flush();  
   pw.close();  
   */
   session.flush();
   logger.info("handle 3333333333");
   tx.commit();

你可能感兴趣的:(oracle,sql,Hibernate,weblogic)