我们正面临 c3p0 连接池的问题。如果 在没有 blob 数据的情况下保存,将 blob 添加到对象,然后 session 保存方法失败。即使它没有出现异常处理程序,它也会直接 finally 阻塞 其中 session.flush 抛出断言异常,因为新 ID 未分配给对象。
有人遇到过这个问题吗?这是配置问题吗?
hibernate 配置
org.hibernate.dialect.MySQL5Dialect
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
<prop key="hibernate.jdbc.batch_size">100</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="org.hibernate.cache.ehcache.configurationResourceName">ehcache.xml</prop>
<prop key="hibernate.max_fetch_depth">4</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.c3p0.max_size">200</prop>
<prop key="hibernate.c3p0.acquire_increment">1</prop>
<prop key="hibernate.c3p0.timeout">1800</prop>
<prop key="hibernate.c3p0.max_statements">100</prop>
<prop key="hibernate.c3p0.idle_test_period">3000</prop>
<prop key="hibernate.c3p0.validationQuery">SELECT 1</prop>
<prop key="hibernate.connection.release_mode">after_transaction</prop>
<prop key="hibernate.id.new_generator_mappings">false</prop>
<prop key="hibernate.search.default.directory_provider">filesystem</prop>
<prop key="hibernate.search.default.indexBase" >/var/lucene/indexes</prop>
谢谢 莫辛
最佳答案
捕获 Throwable 对象并打印堆栈跟踪。
catch(Throwable e){
e.printStackTrace();
}
得到了
java.lang.AbstractMethodError: 方法 com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V 是抽象的 在 com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setBinaryStream(NewProxyPreparedStatement.java) 在 org.hibernate.type.descriptor.sql.BlobTypeDescriptor$5$1.doBind(BlobTypeDescriptor.java:130) 在 org.hibernate.type.descriptor.sql.BlobTypeDescriptor$2$1.doBind(BlobTypeDescriptor.java:86) 在 org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73)
看来c3p0 jar文件使用的是旧的,下载了较新的版本0.0.95.2版本,它有效
谢谢
关于java - c3p0 连接池 saveorupdate with blob data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37320614/