Java JPQL内部的铸造
项目实体已扩展到另一个属性为Vmp的实体Amp。如何在Jpql中查询Vmp。我可以在Jpql内部进行铸造吗 我使用了Jpql,但没有像这样进行转换Java JPQL内部的铸造,java,jpa,jpql,Java,Jpa,Jpql,项目实体已扩展到另一个属性为Vmp的实体Amp。如何在Jpql中查询Vmp。我可以在Jpql内部进行铸造吗 我使用了Jpql,但没有像这样进行转换 select i from Stock i where i.stock >:s and i.department=:d and i.itemBatch.item.vmp=:vmp order by i.itemBatch.item.name ItemBatch具有Item类的属性,但我只收回Amp实体,它扩展了Item类。只有Amp具有Vmp
select i from Stock i where i.stock >:s and i.department=:d and i.itemBatch.item.vmp=:vmp order by i.itemBatch.item.name
ItemBatch具有Item类的属性,但我只收回Amp实体,它扩展了Item类。只有Amp具有Vmp属性。因此,上面的Jpql给出了以下错误
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [select i from Stock i where i.stock >:s and i.department=:d and i.itemBatch.item.vmp=:vmp order by i.itemBatch.item.name].
[85, 105] The state field path 'i.itemBatch.item.vmp' cannot be resolved to a valid type.
我可以像下面这样在Jpql内部强制转换吗?还有其他解决方法吗
select i from Stock i where i.stock >:s and i.department=:d and Atm(i.itemBatch.item).vmp=:vmp order by i.itemBatch.item.name
我找到了方法,只好用治疗代替石膏。这是Jpql
jpql = "select i from Stock i join treat(i.itemBatch.item as Amp) amp where i.stock >:s and i.department=:d and amp.vmp=:vmp order by i.itemBatch.item.name";