当前位置: 首页 > 知识库问答 >
问题:

JPAQuery(QueryDSL)中的非致命用户错误

伊锦
2023-03-14
ID   LABEL  P_ID
1    A      null 
2    AB     1
3    ABC    2
SELECT * FROM ACT
JOIN ORG DEPT ON ACT.ORGID = DEPT.ID
JOIN ORG DEPT2 ON DEPT.P_ID = DEPT2.ID
WHERE DEPT.P_ID = 123
query.join(act.org, dept).on(act.org.id.eq(dept.id)).where(dept.org.parent.eq(123));

O DEBUG JPAQuery-从Dossier dossier_left join dossier_.acties action_inner join action_.organizatiestructuur organizatiestructuur_on action_.organizatiestructuur.id=organizatiestructuur_.id where dossier_.deleted=?1而organizatiestructuur_.ouder=?2

ArgumentException:“在字符64处”遇到“,但应为:[”,“,”group“,”having“,”inner“,”join“,”left“,”order“,”where“,].”解析JPQL时,“从Dossier dossier_left join dossier_.acties action_inner join action_.organistieStructuur organistieStructuur on action_.organistieStructuur.id=organistieStructuur.id where dossier_.deleted=?1和organistieStructuur.ouder=?2”。

[添加9-feb:]域模型(只显示包含字段的第一部分,其他getter/setter方法由于大小而未显示):

@Entity
public class Dossier extends AbstractEntity implements Serializable, HasCommunicaties {
private static final String SHAREPOINT_NR_FORMAT = "{0,number,0000}/{1,number,00}";

@Version
private long version;

private int jaar;
private int volgNummer;

private Status status;

public enum Status {
    OPEN, AFGESLOTEN;
}

@Temporal(TemporalType.TIMESTAMP)
private Date datumStatus;

@NotNull
@Column(length = 5000)
@Size(max = 5000)
private String beschrijvingVaststelling;
@Column(length = 5000)
@Size(max = 5000)
private String oorzaakVaststelling;

@ManyToOne
private ZorgDomein zorgDomein;
@ManyToOne(fetch = FetchType.LAZY)
@NotNull
private Bron bron;

@ManyToOne
private KernWaarde kernWaarde;

private String pdca;

@Valid
@OneToMany(mappedBy = "dossier", cascade = CascadeType.ALL, orphanRemoval = true)
@Size(min = 1)
private List<PlaatsVaststelling> plaatsVaststellingen = new ArrayList<PlaatsVaststelling>();

@ManyToOne(fetch = FetchType.LAZY)
private Proces proces;
@NotNull
private String beheerder;
@Temporal(TemporalType.DATE)
@Past
private Date datumVaststelling;
@ManyToOne(fetch = FetchType.LAZY)
private TypeVaststelling typeVaststelling;
@ManyToOne(fetch = FetchType.LAZY)
private Prioritering prioritering;
@ManyToOne(fetch = FetchType.LAZY)
private AuditRapport auditRapport;

@OneToMany(mappedBy = "dossier", cascade = CascadeType.ALL)
@OrderBy("volgnummer")
@Valid
private List<Actie> acties = new ArrayList<Actie>();
@OneToMany(mappedBy = "dossier")
@OrderBy("datum desc")
private List<Communicatie> communicaties = new ArrayList<Communicatie>();
@OneToMany(mappedBy = "dossier", cascade = CascadeType.ALL)
@OrderBy("datum desc")
private List<Historiek> historieks = new ArrayList<Historiek>();

private boolean vertrouwelijk;
@ElementCollection
private List<String> beheerders = new ArrayList<String>();
@ElementCollection
private List<String> lezers = new ArrayList<String>();

private boolean mailPVAVerstuurd;
private Date datumAanpakTegen;


private boolean deleted;

共有1个答案

澹台臻
2023-03-14

此SQL

SELECT * FROM ACT
JOIN ORG DEPT ON ACT.ORGID = DEPT.ID
JOIN ORG DEPT2 ON DEPT.P_ID = DEPT2.ID
WHERE DEPT.P_ID = 123

可以通过

QAct act = QAct.act;
QOrg dept = new QOrg("dept");
QOrg dept2 = new QOrg("dept2");
query.from(act)
     .join(act.org, dept)
     .join(dept.p, dept2)
     .where(dept2.p.id.eq(123))
     .list(act);

我不确定如何将SQL映射到您的域模型,这就是为什么我使用了与SQL关系相近的实体名称。

 类似资料: