java.lang.ClassCastException: [Ljava.lang.Object; incompatible with com.shkco.adsr3.cbm.vo.ICustomerAccount
看到这错误都知道是数据类型转换不匹配,Object 与ICustomerAccount.
DAO 方法原始如下:
public List<ICustomerAccount> getListOfCustomerAccount(ISessionContext sessionContext, IClientCentricCustomer clientCentricCustomer) { ISessionWrapper session = getCurrentSession(); String sqlStr = "from " + CustomerAccount.class.getName() + " as cust join cust.companyGroup as cg where cg.compGrpId = " + ":companyGroupId " + " and cust.ccdRef= :ccdRef "; Query query = session.createQuery(sqlStr); query.setParameter("companyGroupId", getCompGrpId(sessionContext)); query.setParameter("ccdRef", clientCentricCustomer); return query.list(); }
没有注意看代码,因为是直接写的from .....没有写select 对象,所以返回的就是Object.
修改如下即可:
加上Select cust,即ICustomerAccount 对象就ok啦。
public List<ICustomerAccount> getListOfCustomerAccount(ISessionContext sessionContext, IClientCentricCustomer clientCentricCustomer) { ISessionWrapper session = getCurrentSession(); String sqlStr = "select cust from " + CustomerAccount.class.getName() + " as cust join cust.companyGroup as cg where cg.compGrpId = " + ":companyGroupId " + " and cust.ccdRef= :ccdRef "; Query query = session.createQuery(sqlStr); query.setParameter("companyGroupId", getCompGrpId(sessionContext)); query.setParameter("ccdRef", clientCentricCustomer); return query.list(); }
相关推荐
• 属性的类型为 java.sql.Clob or java.sql.Blob, 则映射到 @Lob 对应的类型。 映射主键属性 @Id 注解可将实体Bean中某个属性定义为主键,使用@GenerateValue注解可以定义该标识符的生成策略。 • AUTO - 可以是...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤器(filters) 18. XML映射 ...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤器(filters) 18. XML映射 ...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤器(filters) 18. XML映射 ...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤器(filters) 18. XML映射 ...
16.3.1. 使用return-property来明确地指定字段/别名 16.3.2. 使用存储过程来查询 16.3.2.1. 使用存储过程的规则和限制 16.4. 定制SQL用来create,update和delete 16.5. 定制装载SQL 17. 过滤数据 17.1. Hibernate ...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.2.2.1. 使用存储过程的规则和限制 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate ...
17.3.1. 使用return-property来明确地指定字段/别名 17.3.2. 使用存储过程来查询 17.3.2.1. 使用存储过程的规则和限制 17.4. 定制SQL用来create,update和delete 17.5. 定制装载SQL 18. 过滤数据 18.1. ...
使用return-property来明确地指定字段/别名 16.3.2. 使用存储过程来查询 16.3.2.1. 使用存储过程的规则和限制 16.4. 定制SQL用来create,update和delete 16.5. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate 过滤器(filters) 18. XML映射 ...
17.3.1. 使用return-property来明确地指定字段/别名 17.3.2. 使用存储过程来查询 17.3.2.1. 使用存储过程的规则和限制 17.4. 定制SQL用来create,update和delete 17.5. 定制装载SQL 18. 过滤数据 18.1. ...
16.3.1. 使用return-property来明确地指定字段/别名 16.3.2. 使用存储过程来查询 16.3.2.1. 使用存储过程的规则和限制 16.4. 定制SQL用来create,update和delete 16.5. 定制装载SQL 17. 过滤数据 17.1. Hibernate ...
使用return-property来明确地指定字段/别名 17.3.2. 使用存储过程来查询 17.3.2.1. 使用存储过程的规则和限制 17.4. 定制SQL用来create,update和delete 17.5. 定制装载SQL 18. 过滤数据 18.1. Hibernate ...
16.2.1. 使用return-property来明确地指定字段/别名 16.2.2. 使用存储过程来查询 16.2.2.1. 使用存储过程的规则和限制 16.3. 定制SQL用来create,update和delete 16.4. 定制装载SQL 17. 过滤数据 17.1. Hibernate ...
14.2.1. 使用return-property来明确地指定字段/别名 14.2.2. 使用存储过程来查询 14.2.2.1. 使用存储过程的规则和限制 14.3. 定制SQL用来create,update和delete 14.4. 定制装载SQL 15. 过滤数据 15.1. NHibernate ...
14.2.1. 使用return-property来明确地指定字段/别名 14.2.2. 使用存储过程来查询 14.2.2.1. 使用存储过程的规则和限制 14.3. 定制SQL用来create,update和delete 14.4. 定制装载SQL 15. 过滤数据 15.1. NHibernate ...