[英]How to write SQL to JPQL
I am learning JPQL, but I think this is very complex, I am good sql server user, but I cant translate this, help please.我正在学习 JPQL,但我认为这很复杂,我是一个很好的 sql server 用户,但我无法翻译这个,请帮忙。
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))
You'll need to switch " * " to "l", in front of parameter names you should use " : " and instead of name tables you'll have the name of the class that represents the entity that you're using.您需要将“*”切换为“l”,在您应该使用“:”的参数名称之前,您将拥有代表您正在使用的实体的类的名称,而不是名称表。 So in the end you'll have something like:
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))
所以最后你会得到类似的东西:
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.