cannot convert clob to string

别说谁变了你拦得住时间么 提交于 2019-12-05 21:05:15

In your hibernate entity (which we can't see) declare the property to be of type String and annotate it with @Lob (again, I don't know whether you are using annotations or XML), and it will work without the need for any manual conversion.

This happens because at the time you are trying to parse the entity, the session and the underlying connection are closed, so you can't stream the value of the CLOB from the database.

An alternative for the above solution might be to use an OpenSessionInView Filter. It will let you have the session (and the underlying database connection) open while rendering the view (i.e. your jsps)

Where are you getting the CLOB from? Is the Connection that created it still open? The error message seems to indicate the database connection has been closed in the meantime. If you are using Hibernate, is the Hibernate Session still open?

starwin

Clob resume = Hibernate.createClob ( "This is Clob");

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!