我有以下 HQL 语句:
Query q = session.createQuery(
"SELECT ze " +
"FROM NormaleZone zo " +
"LEFT JOIN zo.zaal za " +
"LEFT JOIN za.vertoningen v " +
"LEFT JOIN zo.normaleZetels ze " +
"WHERE v = :vertoning " +
" AND zo = :zone " +
" AND ze NOT IN (SELECT t.zetel FROM Ticket t WHERE t.vertoning = :vertoning)"
);
我遇到的问题是NormaleZone
继承自Zone
,HandicapZone
和LoveZone
.
我想做的是以下几点:
Query q = session.createQuery(
"SELECT ze " +
"FROM Zone zo " +
"LEFT JOIN zo.zaal za " +
"LEFT JOIN za.vertoningen v " +
"LEFT JOIN zo.??? ze " +
"WHERE v = :vertoning " +
" AND zo = :zone " +
" AND ze NOT IN (SELECT t.zetel FROM Ticket t WHERE t.vertoning = :vertoning)"
);
你可以看到我放在zo.???
那里。此 HQL 的目的是找出电影院中哪些座位尚未被占用。问题是抽象类Zone
没有座位(这ze
将是座位的别名)。
Zone
除了查看该方法中的传入对象然后制作两个字符串,一个用于区域,一个用于座位,然后将它们连接到 HQL 字符串中,我不明白如何解决这个问题。