I wrote the following piece of code, which is working:
@Query(value = "Select s.* from cost s where s.price1 = :#{#req.price1} and s.price2 = :#{#req.price2}", nativeQuery = true)
List<Cost> findNative(PriceQueryRequest req);
And now I need to use orm.xml, but when I try put the exact same string in XML like below:
<named-native-query name="Cost.findNative">
<query>
<![CDATA[
Select s.* from cost s where s.price1 = :#{#req.price1} and s.price2 = :#{#req.price2}
]]>
</query>
I'm getting the exception "QueryException: Space is not allowed after parameter prefix ':'"
My question is how to use SpEL in orm.xml?
I can't unwrap my DTO and send separate query params, the only way I have is through a DTO.