【发布时间】:2016-08-03 05:09:12
【问题描述】:
我有这个结构:
public enum SaleItemType {
CRUISE,
DAILY_HOSTING
}
public class Estimate {
...
private List<SaleItemType> interestedSaleItemTypes;
@Column(name = "sale_item_type")
@CollectionTable(name = "estimate_sale_item_type", joinColumns = @JoinColumn(name = "estimate_id"))
@ElementCollection(targetClass = SaleItemType.class)
@Enumerated(EnumType.STRING)
public List<SaleItemType> getInterestedSaleItemTypes() {
return interestedSaleItemTypes;
}
}
我正在尝试做一个简单的查询:
String q = "FROM " + Estimate.class.getSimpleName() + " e" + " WHERE e.interestedSaleItemTypes IN :a";
TypedQuery<Estimate> query1 = getEm().createQuery(q, Estimate.class);
query1.setParameter("a", EnumSet.of(SaleItemType.CRUISE));
query1.getResultList();
我在日志中收到此查询(和错误):
DEBUG SQL:92 - 选择estimate0_.id 作为id1_25_,estimate0_.average_ticket 作为average_2_25_,estimate0_.description 作为descript3_25_,estimate0_.end_date 作为end_date4_25_,estimate0_.pax_quantity 作为pax_quan5_25_,estimate0_.start_date 作为start_da6_25_ 来自estimate0_cross join感兴趣1_ whereestimate0_.id=interested1_.estimate_id 和 (.in (?))
调试 SqlExceptionHelper:124 - 无法提取 ResultSet [n/a] org.postgresql.util.PSQLException: 没有为参数 1 指定值。
为什么hibernate会做这个查询?
我使用的是 Hibernate 5.1 Final
【问题讨论】:
标签: java hibernate postgresql jpa