Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPQL内部的铸造_Java_Jpa_Jpql - Fatal编程技术网

Java 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

项目实体已扩展到另一个属性为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属性。因此,上面的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";