gpt4 book ai didi

java - 如何将 SQL 转换为 JPQL 查询?

转载 作者:行者123 更新时间:2023-11-29 03:18:21 25 4
gpt4 key购买 nike

我有这个返回计数的 SQL 查询

头等舱:

public class Niveau2  implements Serializable{
@Id
@GeneratedValue
private int id2emeniveau;
private int ok;
private int next;
private Date date;

@ManyToOne
@JoinColumn(name = "idzebra")
private Zebra zebra;

第二类:

public class Zebra implements Serializable {
@Id
@GeneratedValue
private Integer idzebra;
private String type;
private int resolution;
private int reseau;
private String adresseip;
private String snum;
private Date dateaqui;
private Integer affectter;
private int etat;
private String poste, ligne, zone, pole;

@OneToMany(mappedBy = "zebra")
private List<Niveau2> niveau2;

SQL:

SELECT COUNT(ok) FROM mydb.2emeniveau 
INNER JOIN mydb.zebra ON zebra.idzebra=2emeniveau.idzebra
WHERE 2emeniveau.ok='0' AND zebra.pole='ADT'"

我想把它转成jpql

最佳答案

试试这个:

SELECT COUNT(nv2) FROM Niveau2 nv2 
JOIN nv2.zebras zebras
WHERE nv2.ok = '0' AND zebras.pole = 'ADT'

关于java - 如何将 SQL 转换为 JPQL 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50425928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com