梦凡AI 2023-03-08 17:05 采纳率: 0%
浏览 22

求牛子解决,hibernate5偶发性查询异常

使用hibernate 偶尔会出现这种问题,疑似是不同的线程使用的同一个session,仅是怀疑,没有找到问题,而且不好复现,

通过SessionFactory获取的session
Session session = entityManagerFactory.unwrap(SessionFactory.class).getCurrentSession();


    /**
     * 设置Hibernate的配置属性
     * @return
     */
    private Properties hibernateProperties() {

        Properties properties = new Properties();

        properties.setProperty("hibernate.current_session_context_class", "org.springframework.orm.hibernate5.SpringSessionContext");
        properties.setProperty("current_session_context_class", "org.hibernate.context.internal.ThreadLocalSessionContext");
        properties.setProperty("hibernate.hbm2ddl.auto", environment.getProperty("spring.jpa.hibernate.ddl-auto"));
        properties.setProperty("hibernate.show-sql", environment.getProperty("spring.jpa.properties.hibernate.show-sql"));
        properties.setProperty("connection.autoReconnect","true");
        properties.setProperty("connection.autoReconnectForPools","true");
        properties.setProperty("connection.is-connection-validation-required","true");
        //properties.setProperty("hibernate.cache.use_second_level_cache", ache.use_query_cache"));
        //properties.setProperty("","");
        return properties;

    }

报错信息:

org.springframework.orm.hibernate5.HibernateSystemException: Could not extract result set metadata; nested exception is org.hibernate.HibernateException: Could not extract result set metadata
    at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:300)
    at org.springframework.orm.hibernate5.HibernateExceptionTranslator.convertHibernateAccessException(HibernateExceptionTranslator.java:102)
    at org.springframework.orm.hibernate5.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:77)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)


Caused by: org.hibernate.HibernateException: Could not extract result set metadata
    at org.hibernate.loader.custom.JdbcResultMetadata.<init>(JdbcResultMetadata.java:35)
    at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:476)
    at org.hibernate.loader.Loader.processResultSet(Loader.java:2214)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2170)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893)
    at org.hibernate.loader.Loader.doQuery(Loader.java:938)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
    at org.hibernate.loader.Loader.doList(Loader.java:2692)
    at org.hibernate.loader.Loader.doList(Loader.java:2675)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)
    at org.hibernate.loader.Loader.list(Loader.java:2502)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:335)
    at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2162)
    at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1016)
    at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:152)
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
    at org.bizf.common.dao.impl.QueryServiceImpl.list(QueryServiceImpl.java:188)
    at 
  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-03-08 21:25
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 3月8日

悬赏问题

  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败
  • ¥15 用Ros中的Topic通讯方式控制小乌龟的速度,走矩形;编写订阅器代码
  • ¥15 LLM accuracy检测
  • ¥15 pycharm添加远程解释器报错
  • ¥15 如何让子窗口鼠标滚动独立,不要传递消息给主窗口
  • ¥15 如何能达到用ping0.cc检测成这样?如图
  • ¥15 关于#DMA固件#的问题,请各位专家解答!
  • ¥15 matlab生成的x1图不趋于稳定,之后的图像是稳定的水平线
  • ¥15 请问华为OD岗位的内部职业发展通道都有哪些,以及各个级别晋升的要求
  • ¥20 微信小程序 canvas 问题