hello,everyone: I got an amazing problem, I want to insert or update one record into a table (oracle 8.1.7) which has a Clob type column. If I use only Hibernate, I use the following code, such as:
2 bo.setContentClob(Hibernate.createClob(" ")); 3 session.save(bo); 4 session.flush(); 5 session.refresh(bo, LockMode.UPGRADE); //grabs an Oracle CLOB 6 oracle.sql.CLOB clob = (oracle.sql.CLOB) bo.getContentClob(); 7 java.io.Writer pw = clob.getCharacterOutputStream(); 8 pw.write(content); 9 pw.flush(); 10 pw.close(); 11 session.flush(); it's work fine! I can insert and update. But if I combine Hibernate and Spring, using the beanFactory to invoke this method, such as: public void updateArticle(Article article) throws DataAccessException { Session session = openSession(); try { String content = article.getContent(); article.setContentClob(Hibernate.createClob(" ")); session.update(article); session.flush(); session.refresh(article, LockMode.UPGRADE); /**************************************/ CLOB clob = (CLOB)article.getContentClob(); a ClassCastException will be thrown here! /****************************************/ java.io.Writer pw = clob.getCharacterOutputStream(); pw.write(content); pw.close(); session.flush(); } catch (HibernateException e) { e.printStackTrace(); throw SessionFactoryUtils.convertHibernateAccessException(e); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } I will got a classcastexception, this problem has puzzled me one day, can somebody give me some advices about this problem? Thanks very much! yan,xing ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel