简体   繁体   English

org.hibernate.exception.GenericJDBCException:执行此代码时无法执行查询异常

[英]org.hibernate.exception.GenericJDBCException: could not execute query Exception while executing this code

` `

Hi, I am getting above Exception while executing this function.Here i am trying to fetch distinct of a particular column.嗨,我在执行这个函数时遇到了异常。在这里我试图获取特定列的不同。 Please help me solve this issue...`.Thanks in advance.请帮我解决这个问题...`. 提前致谢。

public List<Object[]> findDistinctProductBrand(){
    SQLQuery squery =null;
    try{
        Session session= sessionFactory.openSession();
        squery =(SQLQuery) session.createSQLQuery("select distinct product_brand from ecm_product").addEntity(EcmProduct.class).list();

    }catch(Exception e){
        System.out.println("Exception in ProductDaoImpl inside findDistinctproductBrand "+e);
    }
    return squery.list();
}  

I think you need to use Transformers in ur code .我认为您需要在您的代码中使用 Transformers。 give it a Try:试一试:

String sql = "select distinct product_brand from ecm_product";
//or     String sql = "select distinct(product_brand) from ecm_product";//no difference actually
SQLQuery query = session.createSQLQuery(sql);
query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
List results = query.list();

and you may follow this你可以按照这个

Let me know if it works.让我知道它是否有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ested异常是org.hibernate.exception.GenericJDBCException:无法执行查询 - ested exception is org.hibernate.exception.GenericJDBCException: could not execute query org.hibernate.exception.GenericJDBCException:无法执行查询]的根本原因 - org.hibernate.exception.GenericJDBCException: could not execute query] with root cause org.hibernate.exception.GenericJDBCException:无法执行查询 - org.hibernate.exception.GenericJDBCException: could not execute query org.hibernate.exception.GenericJDBCException:无法执行查询 - org.hibernate.exception.GenericJDBCException: could not execute query substr错误:org.hibernate.exception.GenericJDBCException:无法执行查询 - substr error: org.hibernate.exception.GenericJDBCException: could not execute query org.hibernate.exception.GenericJDBCException:无法在hibernate中执行语句 - org.hibernate.exception.GenericJDBCException: could not execute statement in hibernate org.hibernate.exception.GenericJDBCException:无法执行语句 - org.hibernate.exception.GenericJDBCException: could not execute statement org.hibernate.exception.GenericJDBCException:无法插入: - org.hibernate.exception.GenericJDBCException: could not insert: 更新查询的 JPA @Query 注释(oracle sql 开发人员)--org.hibernate.exception.GenericJDBCException:无法执行查询 - JPA @Query annotation for update query (oracle sql developer) -- org.hibernate.exception.GenericJDBCException: could not execute query 谁能告诉我为什么会这样“ org.hibernate.exception.GenericJDBCException:无法执行查询”? - Can anyone tell me why this is happening “org.hibernate.exception.GenericJDBCException: could not execute query”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM