如何在Hibernate中查询地图属性?
我正在学习 HQL,并且我有一个具有如下所示的 Map 属性的对象:
@ElementCollection
@JoinTable(name = "InfoLicenzaOrdine", joinColumns = @JoinColumn(name = "infolicenza"))
@Column(length = 64000)
public Map<String, String> getInformazioniDiLicenza() {
return informazioniDiLicenza;
}
public void setInformazioniDiLicenza(
Map<String, String> informazioniDiLicenza) {
this.informazioniDiLicenza = informazioniDiLicenza;
}
现在,像这样的 HQL 查询
select ordine from Ordine ordine where ordine.informazioniDiLicenza['codiceAccisa1'] = 'IT00NOV00029W'
将返回具有映射的特定键的该值的所有对象。如果我只想要具有该值的所有对象而不考虑键怎么办?
I'm learning HQL and I've an object with a Map property like this:
@ElementCollection
@JoinTable(name = "InfoLicenzaOrdine", joinColumns = @JoinColumn(name = "infolicenza"))
@Column(length = 64000)
public Map<String, String> getInformazioniDiLicenza() {
return informazioniDiLicenza;
}
public void setInformazioniDiLicenza(
Map<String, String> informazioniDiLicenza) {
this.informazioniDiLicenza = informazioniDiLicenza;
}
Now an HQL query like:
select ordine from Ordine ordine where ordine.informazioniDiLicenza['codiceAccisa1'] = 'IT00NOV00029W'
will return all the objects with that value for that particular key of the map. What if I just want all the objects with that value regardless of the key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果通过任意键存储“IT00NOV00029W”,则将选择 Ordine。小心点
In case when 'IT00NOV00029W' is stored by any key Ordine will be selected. Be carefull
另请参阅:
See also: