【发布时间】:2016-05-02 08:20:04
【问题描述】:
这失败了:
public List<TypeActionCommerciale> requestTypeActionCommercialeSansNip() throws PersistenceException {
Query query = createQuery("from TypeActionCommercialeImpl where type != :type1");
query.setParameter("type1", TypeActionCommercialeEnum.NIP);
return (List<TypeActionCommerciale>) query.list();
}
例外:
Hibernate:选择 typeaction0_.id 作为 id1_102_,typeaction0_.libelle 作为 libelle3_102_,typeaction0_.code 为 code4_102_,typeaction0_.type 为 type5_102_ 来自 apex.typeActionCommerciale typeaction0_ 其中 typeaction0_.type?
错误 org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:129)
- 没有为参数 1 org.hibernate.exception.DataException 指定值:无法在以下位置提取 ResultSet
我使用 setProperties 但我有同样的错误:
public List<TypeActionCommerciale> requestTypeActionCommercialeSansNip() throws PersistenceException {
Query query = createQuery("from TypeActionCommercialeImpl where type <> :type1");
final Map<String, Object> properties = new HashMap<>();
properties.put("type1", TypeActionCommercialeEnum.NIP);
query.setProperties(properties);
return (List<TypeActionCommerciale>) query.list();
}
【问题讨论】:
-
嘿家伙,也许你必须使用 setProperties 方法。试试看!
-
查询良好。问题表明缺少参数 1。 TypeActionCommercialeEnum.NIP 在哪里?就像它不在类路径中一样。您可以尝试“from TypeActionCommercialeImpl where type != TypeActionCommercialeEnum.NIP”(并删除 setParameter 行)来查看您遇到的错误
-
@IanMc 错误:
org.hibernate.QueryException: Unable to resolve path [TypeActionCommercialeEnum.NIP], unexpected token [TypeActionCommercialeEnum] [from com.metier.impl.TypeActionCommercialeImpl where type != TypeActionCommercialeEnum.NIP] -
更好。现在您可以专注于真正的问题了。
-
如何在Entity类中定义类型?
标签: java hibernate postgresql jpa