多个Join中的HQL无效路径

时间:2017-03-07 14:15:11

标签: hibernate hql

我试图在HQL中翻译此查询:

SELECT t2.code_acs, t3.lib, t5.libelle
FROM
    debit t1
    INNER JOIN saci t2 ON t1.mat_dep=t2.dep
    INNER JOIN departement t5 ON t5.numero = t2.dep
    INNER JOIN dbo.rushServices t3 ON t2.code_acs=t3.acs
    LEFT JOIN l_debit_saci t4 ON t4.id_debit=t1.id AND t4.code_acs=t2.code_acs
WHERE t4.code_acs    IS    NULL
ORDER BY t3.lib

我的HQL查询是:

buffer = new StringBuilder();
buffer.append("SELECT SA ");
buffer.append("FROM DebitMod D ");
buffer.append("INNER JOIN SaciMod SA ");
buffer.append("INNER JOIN SA.departement DE ");
buffer.append("WHERE D.id = :debitId ");
buffer.append("AND D.matriculeDepartement = DE.numero");
buffer.append("AND SAS.service is null ");

hqlQuery = session.createQuery(buffer.toString());
hqlQuery.setInteger("debitId", idDebit);

我的三个模特是:

DebitMod:

....
@Column(name = "mat_dep", nullable = false, columnDefinition = "bpchar")
private String matriculeDepartement = null;
....

SaciMod:

....
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dep", nullable = false, columnDefinition = "bpchar")
private DepartementMod departement = null;
....

DepartementMod:

....
@Id
@Column(name = "numero", nullable = false)
private String numero = null;

@Column(name = "libelle", nullable = false)
private String libelle = null;
....

RushServiceMod:

....
@Id
@Column(name = "acs", nullable = false)
private String acs = null;

@Column(name = "lib", nullable = true)
private String libelle = null;

@OneToMany(mappedBy = "service", fetch = FetchType.LAZY)
private Set<SaciMod> sacis = null;
....

DebitSaciMod:

....
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_debit", nullable = false)
private DebitMod debit = null;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "code_acs", nullable = false)
private RushServiceMod service = null;
....

当我测试HQL查询时出现此错误:

org.hibernate.hql.internal.ast.InvalidPathException:路径无效:&#39; DE.numero&#39;

我忘了什么?

感谢您的帮助

0 个答案:

没有答案