1
我有以下HQL語句: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)"
);
我的問題是,從Zone
NormaleZone
繼承,因爲這樣做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字符串拼接它們。