如何将SQL写入JPQL

问题描述 投票:0回答:1

我正在学习JPQL,但是我认为这非常复杂,我是sql服务器的好用户,但是我无法翻译此内容,请提供帮助。

SELECT * FROM liquidacion AS l INNER JOIN tipo_plan AS tp ON l.plan_id = tp.id 
WHERE ((tp.nombre like @nombrePlan OR @nombrePlan IS NULL ) AND 
    (tp.id_ips = @idPlanIps OR @idPlanIps IS NULL) AND
    (l.periodo = @periodo OR @periodo IS NULL))
java sql spring jpql translate
1个回答
0
投票

[您需要将“ *”切换为“ l”,应该在参数名称前面使用“:”,而不是名称表,而是使用代表您所使用实体的类的名称。因此,最终您将获得以下内容:SELECT l FROM Liquidacion AS l INNER JOIN TipoPlan AS tp ON l.plan_id = tp.id WHERE ((tp.nombre like :nombrePlan OR :nombrePlan IS NULL ) AND (tp.id_ips = :idPlanIps OR :idPlanIps IS NULL) AND (l.periodo = :periodo OR :periodo IS NULL))

© www.soinside.com 2019 - 2024. All rights reserved.